I’m trying to use this article to set this up but it is outdated, and I don’t really understand how to use Dockerfiles so I am struggling to follow it properly.
Hi @jviotti we ran a balena push as suggested, but this gave the same errors. We have since removed this line from our docker file (copied from the article I sent previously):
pip3 install sense-hat rtimulib pillow
We now have successfully been able to push to the Balena.
The next step is now sorting out our docker file so that our Node-Red program starts automatically. Can you point me in the right direction?
Hi @jviotti, I’ve had a look at the example project but I’m not sure the best way to use this to solve my issues. The directories seem to be laid out very different from mine - I’m using the node-red projects feature to manage my git directory. I tried copying over some of the files that I saw for example the Dockerfile.template and the docker-compose.yml but when I ran the balena push it said it couldn’t find a dockerfile.
What is the best way to make sure I have all the necessary parts of the directory, without changing it so much that the node-red projects breaks?
Currently, I’m just using a Dockerfile. When I copied the Dockerfile.template it wouldn’t let me push so I copied the contents to a file called “Dockerfile” and changed the device to raspberrypi4, this wouldnt push so I tried it with raspberrypi3 and it let me push to balena.
###
# Build step
###
FROM balenalib/raspberrypi3-debian-node:12-stretch-build as build
RUN JOBS=MAX npm install -g --production --unsafe-perm \
node-red \
node-red-admin \
node-red-contrib-balena
###
# Runtime image
###
FROM balenalib/raspberrypi3-debian-node:12-stretch-run
RUN apt-get update && apt-get install -yq --no-install-recommends \
rpi.gpio \
python-dev \
python-rpi.gpio \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
# Defines our working directory in container
WORKDIR /usr/src/app
# Copy over the files created in the previous step, including lib/, bin/
COPY --from=build /usr/local/bin /usr/local/bin
COPY --from=build /usr/local/lib/node_modules /usr/local/lib/node_modules
# This will copy all files in our root to the working directory in the container
COPY . ./
# server.js will run when container starts up on the device
CMD ["bash", "/usr/src/app/start.sh"]
So you can build it now then what is your issue here?
Our example use docker-compose.yml so you might need to change the COPY . ./ command to correct directory if you use Dockerfile instead, otherwise it will break the CMD ["bash", "/usr/src/app/start.sh"] as start.sh doesn’t exist