Building Artifacts with a Custom Build Script

This page describes building Skaffold artifacts using a custom build script, which builds images using 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 quickstart docs.

For this tutorial, to use buildpacks as a custom builder with Skaffold, please install the following additional tools:

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>

Tutorial - Hello World in Go

This tutorial will be based on the buildpacks example in our repository.

Adding a Custom Builder to Your Skaffold Project

We’ll need to configure your Skaffold config to build artifacts with this custom builder. To do this, we will take advantage of the custom builder in Skaffold.

First, add a file which Skaffold will call to build artifacts:

set -e
images=$(echo $IMAGES | tr " " "\n")

for image in $images
    pack build $image
    if $PUSH_IMAGE
        docker push $image

Then, configure artifacts in your skaffold.yaml to build with

apiVersion: skaffold/v1
kind: Config
    - image:
            - .
      - ./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 custom builder is properly configured by running skaffold build. This command should build the artifacts and exit successfully.

Last modified November 6, 2019: code review changes (579d01a32)