A quick demo of Cloud Native Buildpacks – https://buildpacks.io/
pack,docker, anddiveCLI toolsbrew install buildpacks/tap/pack docker dive
kubectlandkpCLI 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
kpackinto 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
packdocker rmi my-nodejs-app
- Delete the
kpackresources 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
packis installedpack --help
- See what builders
packsuggestspack 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-appdocker inspect my-nodejs-app
- If you ran
packin a sample app above, get back to the directory containing the kpack resourcescd ../../..
- Check that
kpis installedkp --help
- Make sure the
kpackCRDs 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
Imagemanifestkubectl apply -f image.yml
- Check that the
Imagespawned aBuildand 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
kpkp builds logs my-nodejs-app
- Check that a new app image was published to Docker Hub
- Edit the store configuration, changing the
nodejsimage version from1.0.0to1.1.0kubectl 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
Buildand the new build podkubectl get image,build,po
- Stream the build logs using
kpkp builds logs my-nodejs-app
- Check that a new app image was published to Docker Hub