This demo shows how to build a Node.js app using Google Cloud Native Buildpacks while exporting the final image onto a custom run image you build from Chainguard Node.
- builds and tags a CNB run image locally (from a Dockerfile)
- builds the app image with pack using Google’s builder and your run CG image
- runs the final container
- Docker
- pack CLI
- A Node app directory containing package.json (example included in repo)
- Build the Dockerfile.cnb-run
docker build -t REGISTRY/chainguard-node-cnb-run:devtest3 -f Dockerfile .
- Push to a registry (optional)
docker push REGISTRY/chainguard-node-cnb-run:devtest3
- Build the app image with Google Buildpacks (uses project.toml)
pack build node-demo-app:dev \
--builder gcr.io/buildpacks/builder:google-22 \
--run-image 452336408843.dkr.ecr.us-west-2.amazonaws.com/cg-node-cnb-google22-run:devtest3 \
--platform linux/amd64 \
--clear-cache
docker run --rm --platform linux/amd64 --entrypoint cat node-demo-app:dev /etc/os-release
- Test locally
docker run --rm -p 8080:8080 node-demo-app
curl http://localhost:8080/
Expected Result:
─⠠⠵ curl http://localhost:8080/
{"message":"Node Buildpacks + Chainguard demo","environment":"production","node":"v22.22.0"}%
- Optional - Final Hardened Image without npm
docker build -t node-demo-app:final -f final-hardened/Dockerfile .