Version v1.39 of the documentation is no longer actively maintained. The site that you are currently viewing is an archived snapshot. For up-to-date documentation, see the latest version.
Cloud Native Buildpacks
Cloud Native Buildpacks enable building a container image from source code without the need for a Dockerfile.
Skaffold supports building with Cloud Native Buildpacks, requiring only
a local Docker daemon. Skaffold performs the build inside a container
using the builder
specified in the buildpack
config.
On successful build completion, the built image will be pushed to the remote registry. You can choose to skip this step.
Configuration
To use Buildpacks, add a buildpack
field to each artifact you specify in the
artifacts
part of the build
section. context
should be a path to
your source.
Note
In Skaffold 1.11 (schemav2beta5
), the singular buildpack
field was renamed to buildpacks
.
The following options can optionally be configured:
Option | Description | Default |
---|---|---|
builder |
Required builder image used. |
|
runImage |
overrides the stack’s default run image. |
|
env |
environment variables, in the key=value form, passed to the build. Values can use the go template syntax. |
[] |
buildpacks |
a list of strings, where each string is a specific buildpack to use with the builder. If you specify buildpacks the builder image automatic detection will be ignored. These buildpacks will be used to build the Image from your source code. Order matters. | [] |
trustBuilder |
indicates that the builder should be trusted. | false |
projectDescriptor |
path to the project descriptor file. | project.toml |
dependencies |
file dependencies that skaffold should watch for both rebuilding and file syncing for this artifact. |
|
volumes |
support mounting host volumes into the container. |
|
Builder
builder
is required and tells Skaffold which
Builder to use.
Run Image
runImage
is optional and will override the default Run Image.
Artifact Dependency
You can define dependency on other artifacts using the requires
keyword. This can be useful to specify another artifact image as the builder
or runImage
.
build:
artifacts:
- image: image1 # buildpacks artifact
buildpacks:
builder: image2
runImage: image3
requires:
- image: image2
- image: image3
- image: image2 # builder artifact
- image: image3 # run image artifact
local: {}
User defined environment variables
env
makes it possible to configure specific environment variables for buildpacks.
Many buildpacks use environment variables to adjust their detection and the build phases,
such as selecting specific versions of language runtimes.
Note that user’s current environment is not passed through to buildpacks.
Example
The following build
section, instructs Skaffold to build a
Docker image with buildpacks:
apiVersion: skaffold/v2beta5
kind: Config
build:
artifacts:
- image: gcr.io/k8s-skaffold/skaffold-buildpacks
buildpacks:
builder: "gcr.io/buildpacks/builder:v1"
Dependencies
dependencies
tells the skaffold file watcher which files should be watched to
trigger rebuilds and file syncs. Supported schema for dependencies
includes:
Option | Description | Default |
---|---|---|
paths |
should be set to the file dependencies for this artifact, so that the skaffold file watcher knows when to rebuild and perform file synchronization. | [] |
ignore |
specifies the paths that should be ignored by skaffold’s file watcher. If a file exists in both paths and in ignore , it will be ignored, and will be excluded from both rebuilds and file synchronization. Will only work in conjunction with paths . |
[] |
By default, every file in the artifact’s context
will be watched.
Paths and Ignore
Paths
and Ignore
are arrays used to list dependencies.
Any paths in Ignore
will be ignored by the skaffold file watcher, even if they are also specified in Paths
.
Ignore
will only work in conjunction with Paths
, and with none of the other custom artifact dependency types.
buildpack:
builder: "gcr.io/buildpacks/builder:v1"
dependencies:
paths:
- pkg/**
- src/*.go
ignore:
- vendor/**