Building Artifacts with CNCF Buildpacks
This page describes building Skaffold artifacts with buildpacks. Buildpacks enable building language-based containers from source code, without the need for a Dockerfile.
Before you begin
First, you will need to have Skaffold and a Kubernetes cluster set up. To learn more about how to set up Skaffold and a Kubernetes cluster, see the getting started docs.
To use buildpacks with Skaffold, please install the following additional tools:
Tutorial - Hello World in Go
To walk through a buildpacks tutorial, see our buildpacks example.
Adding Buildpacks to Your Skaffold Project
To use buildpacks with your own project, you must choose a buildpack image to build your artifacts. To see a list of available buildpacks, run:
$ pack suggest-builders
Choose a buildpack from the list, making sure your chosen image can detect the runtime your project is written in. Set your default buildpack:
$ pack set-default-builder <insert buildpack image here>
Now, configure your Skaffold config to build artifacts with buildpacks. To do this, we will take advantage of the custom builder in Skaffold.
First, add a
build.sh file which Skaffold will call to build artifacts:
#!/bin/bash set -e images=$(echo $IMAGES | tr " " "\n") for image in $images do pack build $image if $PUSH_IMAGE then docker push $image fi done
Then, configure artifacts in your
skaffold.yaml to build with
apiVersion: skaffold/v1beta13 kind: Config build: artifacts: - image: gcr.io/k8s-skaffold/image custom: buildCommand: build.sh dependencies: paths: - . deploy: kubectl: manifests: - ./k8s/**
List the file dependencies for each artifact; in the example above, Skaffold watches all files in the build context. For more information about listing dependencies for custom artifacts, see the documentation here.
You can check buildpacks are properly configured by running
This command should build the artifacts and exit successfully.