Balenafin + nodejs Starter

#1

Hi!

I’m a balena noob, with a noob question! I would like to start from scratch with a simple nodejs application running on the BalenaFin. I would like to know:

  • Do I need Docker Hub to do this, or is the balena cli good enough?
  • I deployed the simple-server-node application, and wanted to use that to use as a template to create my own app. How would I go about modifying that project to use as a base for my own project? How would I regenerate the package.json and the dockerfiles so that they would pick up the dependencies my project needs?
  • Lastly, I am developing on a mac, for the BalenaFin. What is the recommended workflow for testing code, since a lot of it will not run locally on my Mac (I think, since its hardware dependent on GPIOs and such). Is it just to run in local mode, and push code to the BalenaFin and iterate from there on?

I apologize in advance if these are answered somewhere, but I’ve been scratching my head with no avail.

Cheers!
Ando

#3

Hi @andoshah , Welcome to the community!! I’ll try answer you questions as best I can.

  1. Nope you don’t need a docker hub account at all.
  2. You can just edit the package.json manually, to add the dependencies you would like or you can do it in your dockerfile doing something like RUN npm install <my-package-name>. The Dockerfile is also just written by hand, its effectively just a recipe file of commands you would usually run in a bash terminal session, so you can do installs of debian packages like so RUN apt-get update && apt-get install my-package
  3. For development, the current recommended way is to use local mode with the --live flag, so you can have the device in local mode and then run balena push mydevice.local --live this will then run a live reloading process, so any time you change your source code or Dockerfile, it will update those changes, usually your code should be running in 5 seconds or so, unless you add new dependencies, those can sometimes take a little more time.

Let us know how you get a long and if you get stuck anywhere. Enjoy!