Docker container with NodeJS v8+ running on Alpine Linux
This docker container is intended as the base for running nodejs applications like our node-server micro webserver.
It is available for the amd64, arm32v6 (Raspberry PI) and arm64v8 processor architectures.
|Raspberry PI||area51/rpi-node||latest 8.2.1|
As of Sept 21 2017 this project uses a single Dockerfile for all architectures so the only prerequisites are:
- Architecture has a base alpine image available, named arch/alpine
- The docker host being used is version 1.17+ and has the experimental extensions enabled - see below.
experimental extension: --squash
This is optional but using this will halve the final image size. If your docker server does not have the experimental extensions enabled then remove the --squash option in the build commands.
Build for amd64 (default)
As amd64 is the default platform you can run the build as you would for any other image:
docker build -t my-node:latest --squash .
Build for any architecture
To build on another architecture, simply add --build-arg ARCHITECTURE= to the build command with the supported architecture name. For example:
- amd64 for 64bit AMD/Intel machines
- arm32v6 for 32bit ARM6 machines including all Raspberry PI's
- arm64v8 for 64bit ARM8 machines, used by some cloud providers
The only limitation here is that the docker server in use must be of that architecture and there must be an alpine image available, e.g. amd64/alpine:latest, arm64v8/alpine:latest etc
docker build -t area51/amd64-node:8.2.1 \ --build-arg ARCHITECTURE=amd64 \ --squash .
Build for a specific version of node
You can choose any version of node to build by adding --build-arg VERSION= to the build command with the required version number.
docker build -t area51/amd64-node:8.2.1 \ --build-arg VERSION=8.2.1 \ --squash .
This is the commands I use in the Jenkins builds (formatting just to make it easier to read here)
docker build \ -t area51/amd64-node:8.2.1 \ --pull \ --force-rm=true \ --build-arg ARCHITECTURE=amd64 \ --build-arg VERSION=8.2.1 \ --squash . docker push area51/amd64-node:8.2.1 docker tag area51/amd64-node:8.2.1 area51/amd64-node:latest docker push area51/amd64-node:latest