Node image build with Alpine Linux 3.5
705
Version v7.9.0 built on Alpine Linux.
All versions use the one margussipria/alpine-node repository,
but each version aligns with the following tags (ie, margussipria/alpine-node:<tag>). The sizes are for the
unpacked images as reported by Docker – compressed sizes are about 1/3 of these:
7, 7.9, 7.9.0 – 54.7 MB (npm 4.2.0)$ docker run margussipria/alpine-node:7 node --version
v7.9.0
$ docker run margussipria/alpine-node:7 npm --version
4.2.0
If you don't have any native dependencies, ie only depend on pure-JS npm
modules, then my suggestion is to run npm install locally before running
docker build (and make sure node_modules isn't in your .dockerignore) –
then you don't need an npm install step in your Dockerfile and you don't need
npm installed in your Docker image – so you can use one of the smaller
base* images. (see mhart/alpine-node:base-7)
FROM margussipria/alpine-node:7
WORKDIR /src
ADD . .
# If you have native dependencies, you'll need extra tools
# RUN apk add --no-cache --virtual .build-deps make gcc g++ python \
# && npm install \
# && apk del .build-deps
EXPOSE 3000
CMD ["node", "index.js"]
As Alpine Linux uses musl, you may run into some issues with environments expecting glibc-like behavior – especially if you try to use binaries compiled with glibc. You should recompile these binaries to use musl (compiling on Alpine is probably the easiest way to do this).
Inspired by:
Content type
Image
Digest
Size
16.6 MB
Last updated
over 9 years ago
docker pull margussipria/alpine-node