diff --git a/internal/pkg/convert/node.go b/internal/pkg/convert/node.go index 66d2375..f91294e 100644 --- a/internal/pkg/convert/node.go +++ b/internal/pkg/convert/node.go @@ -265,6 +265,10 @@ func (node *NodeLLB) stepScripts(root llb.State, i int, step v1alpha2.Step) llb. llb.WithCustomName(fmt.Sprintf("%s%s-%d", node.Prefix, script.Desc, i)), ) + if node.Graph.Options.NoCache { + runOptions = append(runOptions, llb.IgnoreCache) + } + root = root.Run(runOptions...).Root() } } diff --git a/internal/pkg/environment/options.go b/internal/pkg/environment/options.go index e4f007c..9308aab 100644 --- a/internal/pkg/environment/options.go +++ b/internal/pkg/environment/options.go @@ -21,6 +21,7 @@ type Options struct { ProxyEnv *llb.ProxyEnv SourceDateEpoch time.Time CacheIDNamespace string + NoCache bool } // GetVariables returns set of variables set for options. diff --git a/internal/pkg/pkgfile/build.go b/internal/pkg/pkgfile/build.go index 38afd2e..dd1c5e2 100644 --- a/internal/pkg/pkgfile/build.go +++ b/internal/pkg/pkgfile/build.go @@ -30,6 +30,7 @@ const ( keyTarget = "target" keyTargetPlatform = "platform" keyMultiPlatform = "multi-platform" + keyNoCache = "no-cache" buildArgPrefix = "build-arg:" buildArgSourceDateEpoch = buildArgPrefix + "SOURCE_DATE_EPOCH" @@ -47,6 +48,7 @@ func Build(ctx context.Context, c client.Client, options *environment.Options) ( options.Target = opts[keyTarget] options.ProxyEnv = proxyEnvFromBuildArgs(filter(opts, buildArgPrefix)) + _, options.NoCache = opts[keyNoCache] if sourceDateEpoch, ok := opts[buildArgSourceDateEpoch]; ok { timestamp, err := strconv.ParseInt(sourceDateEpoch, 10, 64)