Skip to content

ericbannon/google-build-packs-cg

Repository files navigation

Node.js Buildpacks Demo

Google Builder with Custom Chainguard Run Image

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.

What it does

  1. builds and tags a CNB run image locally (from a Dockerfile)
  2. builds the app image with pack using Google’s builder and your run CG image
  3. runs the final container

Prereqs

  • Docker
  • pack CLI
  • A Node app directory containing package.json (example included in repo)

Steps

  1. Build the Dockerfile.cnb-run
docker build -t REGISTRY/chainguard-node-cnb-run:devtest3 -f Dockerfile .
  1. Push to a registry (optional)
docker push REGISTRY/chainguard-node-cnb-run:devtest3
  1. 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
  1. 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"}%
  1. Optional - Final Hardened Image without npm
docker build -t node-demo-app:final -f final-hardened/Dockerfile  .

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors