You just push the sample-app. The sample-app is your node app, right? Here’s a minorly oversimplified example: I have created an node/electron app called “MyAwesomeApp” in a folder of the same name. The only things I need to add to my app to get it to run on the Balena system is a Dockerfile and the start.sh. Everything else in “MyAwesomeApp” is what I decided to put there. Balena looks at the Dockerfile first and then everything runs accordingly. Note: as I understand, the Dockerfile is only seen when the container is being made or remade, not everytime you run the container.
Something I suggest you try is getting the sample app running on it’s own first to see if it works. Always interesting to see if/how a developer wants their code to run
There’s some quirks when getting electron on Balena running. What runs fine on your computer using npm start
doesn’t necessarily translate the way you want (I ran into some issues with running node script on the front end. I think that might have something to do with Electron vs Balena though).
When you get it working you might be slapping yourself in the forehead. But I started knowing nothing about this stuff. I still don’t quite understand how it works, but I have a better understanding of what each step is supposed to do.
Here’s a copy of my Dockerfile that got me off the ground. I can’t tell you why it works like this–and maybe it currently doesn’t. I stopped development of my project because I kept running into issues and have too many other responsibilities at the moment–but it worked for me. I’ll try to explain what I remember below the copy.
FROM balenalib/armv7hf-debian-node:15.10-buster-build
FROM balenalib/armv7hf-debian-node:15.10-buster-run
FROM balenablocks/armv7hf-balena-electron-env:v1.2.6
RUN apt update
RUN apt upgrade
RUN npm install -g n stable
COPY package-lock.json package.json preload.js renderer.js server.js start.sh ./
RUN npm install
(I was running this on a Raspberry Pi 3b+)
FROM
Line 1) I needed to install a build of Linux that worked for my 32bit, armv7hf device. This pulls the necessary build.
Line 2) Instantiates the Linux build.
Line 3) Pulls the armv7hf version of the balena-electron-env. This is basically the Github repo.
Note: There’s a lot going on in the repo that you do not need to be responsible for. That’s what the developers have done. If you want an idea of what they are doing that you do not, take a look at the Dockerfile.template
in the root of the repo.
RUN
Lines 4 & 5) updates the Linux system we’ve installed
Lines 6) installs npm for your app to use
COPY
Line 7) all of the files needed to run your node app including ./
, aka every file included in the root directory.
RUN
Line 8) Don’t remember, lol. But I think it had to do with an issue I was running into where node/npm didn’t quite do everything it needed to do.
Last note, I think balena-electron-env is someone’s side project. It’s a framework that tinkers or people who know more of what they’re doing to use/break/learn on. It’s fun to be able to make something work from seemingly nothing. But part of that fun is the problem solving and weird quirks of unfinished/untested/in-progress code. I tried to use balena-electron-env
as a display board for my company. And to varying degrees, it worked. But it became a pain for one person to fix, play with, and troubleshoot with all the other necessary responsibilities. It was a fun project when times were slow. I wish I could have used it to greater effect. But I had to let my project die. If you’re looking for something that is stable, that is maintained, you might need to look for a paid solution.