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 5 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
6 changes: 6 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 @@ -367,6 +368,11 @@ func GetBuildArgs(a *latest.DockerArtifact) ([]string, error) {
if a.NetworkMode != "" {
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: "noCache",
},
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