Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.
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
2 changes: 2 additions & 0 deletions api/compose/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ type BuildOptions struct {
Progress string
// Args set build-time args
Args types.Mapping
// NoCache disables cache use
NoCache bool
}

// CreateOptions group options of the Create API
Expand Down
12 changes: 12 additions & 0 deletions cli/cmd/compose/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package compose

import (
"context"
"fmt"
"os"

"github.com/compose-spec/compose-go/types"
Expand All @@ -35,6 +36,8 @@ type buildOptions struct {
pull bool
progress string
args []string
noCache bool
memory string
}

func buildCommand(p *projectOptions) *cobra.Command {
Expand All @@ -45,6 +48,9 @@ func buildCommand(p *projectOptions) *cobra.Command {
Use: "build [SERVICE...]",
Short: "Build or rebuild services",
RunE: func(cmd *cobra.Command, args []string) error {
if opts.memory != "" {
fmt.Println("WARNING --memory is ignored as not supported in buildkit.")
}
if opts.quiet {
devnull, err := os.Open(os.DevNull)
if err != nil {
Expand All @@ -65,6 +71,11 @@ func buildCommand(p *projectOptions) *cobra.Command {
cmd.Flags().MarkHidden("compress") //nolint:errcheck
cmd.Flags().Bool("force-rm", true, "Always remove intermediate containers. DEPRECATED")
cmd.Flags().MarkHidden("force-rm") //nolint:errcheck
cmd.Flags().BoolVar(&opts.noCache, "no-cache", false, "Do not use cache when building the image")
cmd.Flags().Bool("no-rm", false, "Do not remove intermediate containers after a successful build. DEPRECATED")
cmd.Flags().MarkHidden("no-rm") //nolint:errcheck
cmd.Flags().StringVarP(&opts.memory, "memory", "m", "", "Set memory limit for the build container. Not supported on buildkit yet.")
cmd.Flags().MarkHidden("memory") //nolint:errcheck

return cmd
}
Expand All @@ -85,6 +96,7 @@ func runBuild(ctx context.Context, opts buildOptions, services []string) error {
Pull: opts.pull,
Progress: opts.progress,
Args: types.NewMapping(opts.args),
NoCache: opts.noCache,
})
})
return err
Expand Down
1 change: 1 addition & 0 deletions local/compose/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func (s *composeService) Build(ctx context.Context, project *types.Project, opti
}
buildOptions.Pull = options.Pull
buildOptions.BuildArgs = options.Args
buildOptions.NoCache = options.NoCache
opts[imageName] = buildOptions
buildOptions.CacheFrom, err = build.ParseCacheEntry(service.Build.CacheFrom)
if err != nil {
Expand Down