diff --git a/docs/content/en/schemas/v2alpha3.json b/docs/content/en/schemas/v2alpha3.json index 3a15dcb5817..31e5c0af616 100755 --- a/docs/content/en/schemas/v2alpha3.json +++ b/docs/content/en/schemas/v2alpha3.json @@ -494,6 +494,15 @@ "description": "builder image used.", "x-intellij-html-description": "builder image used." }, + "buildpacks": { + "items": { + "type": "string" + }, + "type": "array", + "description": "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.", + "x-intellij-html-description": "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.", + "default": "[]" + }, "dependencies": { "$ref": "#/definitions/BuildpackDependencies", "description": "file dependencies that skaffold should watch for both rebuilding and file syncing for this artifact.", @@ -521,6 +530,7 @@ "builder", "runImage", "env", + "buildpacks", "dependencies" ], "additionalProperties": false, diff --git a/pkg/skaffold/build/buildpacks/build_test.go b/pkg/skaffold/build/buildpacks/build_test.go index be02f62fb1a..3178cdc4909 100644 --- a/pkg/skaffold/build/buildpacks/build_test.go +++ b/pkg/skaffold/build/buildpacks/build_test.go @@ -62,6 +62,20 @@ func TestBuild(t *testing.T) { Image: "img:latest", }, }, + { + description: "success with buildpacks", + artifact: withBuildpacks([]string{"my/buildpack", "my/otherBuildpack"}, buildpacksArtifact("my/otherBuilder", "my/otherRun")), + tag: "img:tag", + api: &testutil.FakeAPIClient{}, + expectedOptions: &pack.BuildOptions{ + AppPath: ".", + Builder: "my/otherBuilder", + RunImage: "my/otherRun", + Buildpacks: []string{"my/buildpack", "my/otherBuildpack"}, + Env: map[string]string{}, + Image: "img:latest", + }, + }, { description: "dev mode", artifact: withSync(&latest.Sync{Infer: []string{"**/*"}}, buildpacksArtifact("another/builder", "another/run")), @@ -164,3 +178,8 @@ func withSync(sync *latest.Sync, artifact *latest.Artifact) *latest.Artifact { artifact.Sync = sync return artifact } + +func withBuildpacks(buildpacks []string, artifact *latest.Artifact) *latest.Artifact { + artifact.BuildpackArtifact.Buildpacks = buildpacks + return artifact +} diff --git a/pkg/skaffold/build/buildpacks/lifecycle.go b/pkg/skaffold/build/buildpacks/lifecycle.go index c8a6c73dab5..0be547b0942 100644 --- a/pkg/skaffold/build/buildpacks/lifecycle.go +++ b/pkg/skaffold/build/buildpacks/lifecycle.go @@ -66,12 +66,13 @@ func (b *Builder) build(ctx context.Context, out io.Writer, a *latest.Artifact, alreadyPulled := images.AreAlreadyPulled(artifact.Builder, artifact.RunImage) if err := runPackBuildFunc(ctx, out, pack.BuildOptions{ - AppPath: workspace, - Builder: artifact.Builder, - RunImage: artifact.RunImage, - Env: envMap(env), - Image: latest, - NoPull: alreadyPulled, + AppPath: workspace, + Builder: artifact.Builder, + RunImage: artifact.RunImage, + Buildpacks: artifact.Buildpacks, + Env: envMap(env), + Image: latest, + NoPull: alreadyPulled, }); err != nil { return "", err } diff --git a/pkg/skaffold/schema/latest/config.go b/pkg/skaffold/schema/latest/config.go index c46d87a2e65..eaaa5ebd7ba 100644 --- a/pkg/skaffold/schema/latest/config.go +++ b/pkg/skaffold/schema/latest/config.go @@ -697,6 +697,11 @@ type BuildpackArtifact struct { // For example: `["key1=value1", "key2=value2", "key3={{.ENV_VARIABLE}}"]`. Env []string `yaml:"env,omitempty"` + // Buildpacks is 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. + Buildpacks []string `yaml:"buildpacks,omitempty"` + // Dependencies are the file dependencies that skaffold should watch for both rebuilding and file syncing for this artifact. Dependencies *BuildpackDependencies `yaml:"dependencies,omitempty"` }