A quick demo of Cloud Native Buildpacks – https://buildpacks.io/
pack
,docker
, anddive
CLI toolsbrew install buildpacks/tap/pack docker dive
kubectl
andkp
CLI toolsbrew install kubernetes-cli vmware-tanzu/kpack-cli/kp
- Docker
- A Kubernetes cluster with at least 4GB memory
- If using Colima, start it with
colima start -k -m4 -ax86_64
- You may also need to export the location of the Docker daemon:
export DOCKER_HOST=unix://$HOME/.colima/default/docker.sock
- If using Colima, start it with
- Clone the Paketo Buildpacks sample apps, paketo-buildpacks/samples, to a local directory
git clone https://github.com/paketo-buildpacks/samples.git
- Install
kpack
into the Kubernetes cluster as described herekubectl apply -f https://github.com/pivotal/kpack/releases/download/v0.9.2/release-0.9.2.yaml
- In your GitHub and Docker Hub account settings, create personal access tokens for each and set them in creds.yml
- Create the secrets for GitHub and Docker Hub
kubectl apply -f creds.yml
- Create the stack, store and builder
kubectl apply -f builder.yml
- Delete any images previously created by
pack
docker rmi my-nodejs-app
- Delete the
kpack
resources for the stack, store, builder and imagekubectl delete -f builder.yml -f image.yml
- Delete builder and app image from Docker Hub (wait for deletion to finish)
- Re-create the stack, store and builder
kubectl apply -f builder.yml
- Get into one of the subdirectories containing a sample app
cd samples/nodejs/npm/
- Examine the contents (note lack of Dockerfile or any other build config)
ls -la
- Make sure
pack
is installedpack --help
- See what builders
pack
suggestspack builder suggest
- Build the app into an image using the Paketo base builder
pack build my-nodejs-app --builder paketobuildpacks/builder:base
- Check that the image was built and is available locally
docker images
- Examine how the layers are composed in the image
dive my-nodejs-app
- Download the SBOM from the image
pack sbom download my-nodejs-app
docker inspect my-nodejs-app
- If you ran
pack
in a sample app above, get back to the directory containing the kpack resourcescd ../../..
- Check that
kp
is installedkp --help
- Make sure the
kpack
CRDs are present in the clusterkubectl api-resources | grep kpack
- Check the readiness of the stack, store and builder
kubectl get clusterstack,clusterstore,builder
- Check the builder image on Docker Hub
- Apply the
Image
manifestkubectl apply -f image.yml
- Check that the
Image
spawned aBuild
and a build podkubectl get image,build,po
- Look into the composition of the build pod, in particular the init containers
kubectl describe pod/my-nodejs-app-build-1-build-pod
- Stream the build logs using
kp
kp builds logs my-nodejs-app
- Check that a new app image was published to Docker Hub
- Edit the store configuration, changing the
nodejs
image version from1.0.0
to1.1.0
kubectl edit clusterstore nodejs
- After a short pause, check that the builder has been updated (spot "Observed Store Generation" and buildpack version)
kubectl describe builder my-nodejs-builder
- Check that a new builder image was published to Docker Hub
- Find the new
Build
and the new build podkubectl get image,build,po
- Stream the build logs using
kp
kp builds logs my-nodejs-app
- Check that a new app image was published to Docker Hub