Skip to content

Allow --no-cache to be passed to docker #2054

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
May 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion docs/content/en/schemas/v1beta10.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 <code>Host</code>: use the host's networking stack. <code>Bridge</code>: use the bridged network configuration. <code>None</code>: 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.",
Expand All @@ -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`.",
Expand Down
5 changes: 5 additions & 0 deletions pkg/skaffold/docker/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
}
7 changes: 7 additions & 0 deletions pkg/skaffold/docker/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
3 changes: 3 additions & 0 deletions pkg/skaffold/schema/latest/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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/).
Expand Down