From 4a9ec26fa5b2e196d6d8889f249025cebfa342e8 Mon Sep 17 00:00:00 2001 From: Remy Adriaanse Date: Thu, 27 Jan 2022 21:40:54 +0100 Subject: [PATCH 1/2] plugin/docker: add no-cache option --- .changelog/2953.txt | 3 +++ builtin/docker/builder.go | 15 ++++++++++++++- .../partials/components/builder-docker.mdx | 9 +++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 .changelog/2953.txt diff --git a/.changelog/2953.txt b/.changelog/2953.txt new file mode 100644 index 00000000000..a177431fc0b --- /dev/null +++ b/.changelog/2953.txt @@ -0,0 +1,3 @@ +```release-note:improvement +plugin/docker: Add parameter to disable the build cache +``` diff --git a/builtin/docker/builder.go b/builtin/docker/builder.go index d1881e2f527..4229d24fa4e 100644 --- a/builtin/docker/builder.go +++ b/builtin/docker/builder.go @@ -71,6 +71,9 @@ type BuilderConfig struct { // Controls the passing of the target stage Target string `hcl:"target,optional"` + + // Disable the build cache + NoCache bool `hcl:"no_cache,optional"` } func (b *Builder) Documentation() (*docs.Documentation, error) { @@ -167,6 +170,14 @@ build { ), ) + doc.SetField( + "no_cache", + "Do not use cache when building the image", + docs.Summary( + "Ensures a clean image build.", + ), + ) + return doc, nil } @@ -309,7 +320,7 @@ func (b *Builder) Build( // Build step.Done() step = nil - if err := b.buildWithDocker(ctx, ui, sg, cli, contextDir, relDockerfile, result.Name(), b.config.Platform, b.config.BuildArgs, b.config.Target, log); err != nil { + if err := b.buildWithDocker(ctx, ui, sg, cli, contextDir, relDockerfile, result.Name(), b.config.Platform, b.config.BuildArgs, b.config.Target, b.config.NoCache, log); err != nil { return nil, err } @@ -384,6 +395,7 @@ func (b *Builder) buildWithDocker( platform string, buildArgs map[string]*string, target string, + noCache bool, log hclog.Logger, ) error { excludes, err := build.ReadDockerignore(contextDir) @@ -432,6 +444,7 @@ func (b *Builder) buildWithDocker( Platform: platform, BuildArgs: buildArgs, Target: target, + NoCache: noCache, } // Buildkit builds need a session under most circumstances, but sessions are only supported in >1.39 diff --git a/website/content/partials/components/builder-docker.mdx b/website/content/partials/components/builder-docker.mdx index 948fef38e44..369a4b1c0fc 100644 --- a/website/content/partials/components/builder-docker.mdx +++ b/website/content/partials/components/builder-docker.mdx @@ -101,6 +101,15 @@ If buildkit is enabled unused stages will be skipped. - Type: **string** - **Optional** +#### no_cache + +Do not use cache when building the image + +Ensures a clean image build. + +- Type: **bool** +- **Optional** + ### Output Attributes Output attributes can be used in your `waypoint.hcl` as [variables](/docs/waypoint-hcl/variables) via [`artifact`](/docs/waypoint-hcl/variables/artifact) or [`deploy`](/docs/waypoint-hcl/variables/deploy). From 38664ed3dcb82bb2ceb968fcd53bcae208adf7aa Mon Sep 17 00:00:00 2001 From: Remy Adriaanse Date: Fri, 28 Jan 2022 00:27:10 +0100 Subject: [PATCH 2/2] fix: website docs --- .../partials/components/builder-docker.mdx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/website/content/partials/components/builder-docker.mdx b/website/content/partials/components/builder-docker.mdx index 369a4b1c0fc..91f6dba1862 100644 --- a/website/content/partials/components/builder-docker.mdx +++ b/website/content/partials/components/builder-docker.mdx @@ -83,6 +83,15 @@ Set this when the Dockerfile is not APP-PATH/Dockerfile. - Type: **string** - **Optional** +#### no_cache + +Do not use cache when building the image. + +Ensures a clean image build. + +- Type: **bool** +- **Optional** + #### platform Set target platform to build container if server is multi-platform capable. @@ -101,15 +110,6 @@ If buildkit is enabled unused stages will be skipped. - Type: **string** - **Optional** -#### no_cache - -Do not use cache when building the image - -Ensures a clean image build. - -- Type: **bool** -- **Optional** - ### Output Attributes Output attributes can be used in your `waypoint.hcl` as [variables](/docs/waypoint-hcl/variables) via [`artifact`](/docs/waypoint-hcl/variables/artifact) or [`deploy`](/docs/waypoint-hcl/variables/deploy).