Stage 0node:22.11-slim
Starts from the base image node, tag 22.11-slim.
A version tag can be re-pushed to different content; only a digest is immutable. This applies to every tagged FROM in the file.
Safer: Pin the digest as well (image:tag@sha256:<digest>) and let a bot open pull requests when it changes.
Sets the working directory to /app for later instructions and the container. It is created if it does not exist.
Copies package.json, package-lock.json from your build context to ./ in the image.
Runs
npm ci --omit=devwhile building the image and saves the result as a new layer.Copies src from your build context to ./src in the image.
Copies .env from your build context to ./ in the image.
Files like .env, private keys and credentials copied into an image stay in that layer even if a later step deletes them, and anyone who can pull the image can extract them.
Safer: Keep the file out of the build (.dockerignore), and use RUN --mount=type=secret for build-time secrets or inject runtime secrets at start.
Runs later instructions and the container's process as user 10001.
Runs
node src/healthcheck.jsto check the container is healthy.Sets the default command to
node src/server.js. It runs when the container starts, and anything passed to docker run replaces it.