diff --git a/docs/content/en/schemas/v1beta10.json b/docs/content/en/schemas/v1beta10.json index 572139fc19c..f5e006b62cf 100755 --- a/docs/content/en/schemas/v1beta10.json +++ b/docs/content/en/schemas/v1beta10.json @@ -729,6 +729,12 @@ "description": "passed through to docker and overrides the network configuration of docker builder. If unset, use whatever is configured in the underlying docker daemon. Valid modes are `Host`: use the host's networking stack. `Bridge`: use the bridged network configuration. `None`: no networking in the container.", "x-intellij-html-description": "passed through to docker and overrides the network configuration of docker builder. If unset, use whatever is configured in the underlying docker daemon. Valid modes are Host: use the host's networking stack. Bridge: use the bridged network configuration. None: no networking in the container." }, + "noCache": { + "type": "boolean", + "description": "used to pass in --no-cache to docker build to prevent caching.", + "x-intellij-html-description": "used to pass in --no-cache to docker build to prevent caching.", + "default": "false" + }, "target": { "type": "string", "description": "Dockerfile target name to build.", @@ -740,7 +746,8 @@ "target", "buildArgs", "network", - "cacheFrom" + "cacheFrom", + "noCache" ], "additionalProperties": false, "description": "*beta* describes an artifact built from a Dockerfile, usually using `docker build`.", diff --git a/pkg/skaffold/docker/image.go b/pkg/skaffold/docker/image.go index 9be2453e9f9..13628906964 100644 --- a/pkg/skaffold/docker/image.go +++ b/pkg/skaffold/docker/image.go @@ -161,6 +161,7 @@ func (l *localDaemon) Build(ctx context.Context, out io.Writer, workspace string Target: a.Target, ForceRemove: l.forceRemove, NetworkMode: a.NetworkMode, + NoCache: a.NoCache, }) if err != nil { return "", errors.Wrap(err, "docker build") @@ -368,5 +369,9 @@ func GetBuildArgs(a *latest.DockerArtifact) ([]string, error) { args = append(args, "--network", strings.ToLower(a.NetworkMode)) } + if a.NoCache { + args = append(args, "--no-cache") + } + return args, nil } diff --git a/pkg/skaffold/docker/image_test.go b/pkg/skaffold/docker/image_test.go index 35c0d8d773b..5e8e1b2e4fa 100644 --- a/pkg/skaffold/docker/image_test.go +++ b/pkg/skaffold/docker/image_test.go @@ -227,6 +227,13 @@ func TestGetBuildArgs(t *testing.T) { }, want: []string{"--network", "bridge"}, }, + { + description: "no-cache", + artifact: &latest.DockerArtifact{ + NoCache: true, + }, + want: []string{"--no-cache"}, + }, { description: "all", artifact: &latest.DockerArtifact{ diff --git a/pkg/skaffold/schema/latest/config.go b/pkg/skaffold/schema/latest/config.go index df7d6522a39..ba6d9927a94 100644 --- a/pkg/skaffold/schema/latest/config.go +++ b/pkg/skaffold/schema/latest/config.go @@ -631,6 +631,9 @@ type DockerArtifact struct { // CacheFrom lists the Docker images used as cache sources. // For example: `["golang:1.10.1-alpine3.7", "alpine:3.7"]`. CacheFrom []string `yaml:"cacheFrom,omitempty"` + + // NoCache used to pass in --no-cache to docker build to prevent caching. + NoCache bool `yaml:"noCache,omitempty"` } // BazelArtifact *beta* describes an artifact built with [Bazel](https://bazel.build/).