Sample Dockerfile and build script for running Node on a Raspberry Pi Zero/1 (armv6)
There is an image for Node and
armv6 processors but in my experience if you have even a medium sized project it takes a long time to run
npm install and I've also had problem with the rpi0 running out of memory. I made this script to easily create the images on a Mac (should work on other OS as well) and then transfer the image to my Pi. That way I can develop my app and the deploy it without having to push to a Docker registry.
On your local machine
First copy the necessary files to your node-project.
cp .dockerignore \ Dockerfile.armv6 \ Dockerfile.armv6.local_npm \ build_arm.sh \ PROJECT_DIR
Make sure your Node version is available as an image for
armv6 and edit the Dockerfiles accordingly.
Build the armv6 image and save it to a tarball.
./build_arm.sh -n [IMAGE_NAME]
./build_arm.sh -n node-docker-raspberry-zero will generate a file
node-docker-raspberry-zero.tar and an image
If you want to transfer the created tar, pass a hostname and path for
./build_arm.sh -d host:/home/pi
If you have NPM installed locally you can fetch
node_modules and then copy them into the image (faster). Make sure you local version works with the one in the Dockerfile.
On your pi
# Load the transfered tar docker load -i node-docker-raspberry-zero.tar
docker run -d --rm --name sample-app \ -p 5000:5000 \ node-docker-raspberry-zero:armv6
- Fork it ( https://github.com/joenas/node-docker-raspberry-zero/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
- joenas joenas - creator, maintainer