While Docker is still most popular for packaging and running Node.js apps in containers, it has security and scalability shortcomings for production systems and build pipelines. Recently alternatives have emerged to build container images without Docker. Each of these address common problems: building without elevated privileges, reproducible results, caching of intermediate layers and scaling CI/CD in larger organizations.
We first introduce the basic structure of a container image and compare the build process for tools supporting Node.js. After demonstrating their usage, we give guidance for selecting the right tool – which might not always be Docker.
Here are some different ways to build the same Node.js example app with different tools.
Build Docker image using Docker daemon. Some best practises are applied and explained, but the build process might not be as secure as desired.
Use experimental BuildKit integration in Docker CLI version 19.03 to build Dockerfile.
Use Makisu to build Dockerfile within an unprivileged container for better isolation and security.
Exporting the resulting image would require setting up a separate remote image registry to push the image.
Let pack
create a Docker image by using a matching Cloud Native Buildpack.
The Dockerfile is not used here.
This repository contains sample code which might be non-functional and not production-ready.
You can open a issue to ask for further help or explanations, but I might not have the time or knowledge to answer everything.
- https://github.com/moby/moby/blob/master/image/spec/v1.2.md
- https://docs.docker.com/engine/security/security/#docker-daemon-attack-surface
- https://nodejs.org/en/docs/guides/nodejs-docker-webapp/
- https://github.com/nodejs/docker-node/blob/master/docs/BestPractices.md
- https://github.com/moby/buildkit
- https://github.com/docker/buildx#building-with-buildx
- https://github.com/GoogleContainerTools/kaniko
- https://github.com/tektoncd/pipeline/blob/master/examples/taskruns/taskrun.yaml
- https://github.com/bazelbuild/rules_nodejs
- https://github.com/bazelbuild/rules_docker/blob/master/README.md#nodejs_image
- https://github.com/GoogleContainerTools/distroless/blob/master/examples/nodejs/BUILD
This content of this repository is licensed under MIT.