Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Commit 3f0ee70

Browse files
author
aiordache
committed
Add no-cache build flag
Signed-off-by: aiordache <[email protected]>
1 parent ee4e85a commit 3f0ee70

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

api/compose/api.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ type BuildOptions struct {
8282
Progress string
8383
// Args set build-time args
8484
Args types.Mapping
85+
// NoCache disables cache use
86+
NoCache bool
8587
}
8688

8789
// CreateOptions group options of the Create API

cli/cmd/compose/build.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ type buildOptions struct {
3535
pull bool
3636
progress string
3737
args []string
38+
noCache bool
39+
memory string
3840
}
3941

4042
func buildCommand(p *projectOptions) *cobra.Command {
@@ -65,6 +67,11 @@ func buildCommand(p *projectOptions) *cobra.Command {
6567
cmd.Flags().MarkHidden("compress") //nolint:errcheck
6668
cmd.Flags().Bool("force-rm", true, "Always remove intermediate containers. DEPRECATED")
6769
cmd.Flags().MarkHidden("force-rm") //nolint:errcheck
70+
cmd.Flags().BoolVar(&opts.noCache, "no-cache", false, "Do not use cache when building the image")
71+
cmd.Flags().Bool("no-rm", false, "Do not remove intermediate containers after a successful build. DEPRECATED")
72+
cmd.Flags().MarkHidden("no-rm") //nolint:errcheck
73+
cmd.Flags().StringVarP(&opts.memory, "memory", "m", "", "Set memory limit for the build container. DEPRECATED")
74+
cmd.Flags().MarkHidden("memory") //nolint:errcheck
6875

6976
return cmd
7077
}
@@ -85,6 +92,7 @@ func runBuild(ctx context.Context, opts buildOptions, services []string) error {
8592
Pull: opts.pull,
8693
Progress: opts.progress,
8794
Args: types.NewMapping(opts.args),
95+
NoCache: opts.noCache,
8896
})
8997
})
9098
return err

local/compose/build.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ func (s *composeService) Build(ctx context.Context, project *types.Project, opti
5050
}
5151
buildOptions.Pull = options.Pull
5252
buildOptions.BuildArgs = options.Args
53+
buildOptions.NoCache = options.NoCache
5354
opts[imageName] = buildOptions
5455
buildOptions.CacheFrom, err = build.ParseCacheEntry(service.Build.CacheFrom)
5556
if err != nil {

0 commit comments

Comments
 (0)