mirror of
https://github.com/docker/compose.git
synced 2025-07-27 15:44:08 +02:00
fix support for BUILDKIT_PROGRESS
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
046879a4a2
commit
693b9ef078
@ -27,7 +27,6 @@ import (
|
|||||||
"github.com/docker/cli/cli/command"
|
"github.com/docker/cli/cli/command"
|
||||||
cliopts "github.com/docker/cli/opts"
|
cliopts "github.com/docker/cli/opts"
|
||||||
ui "github.com/docker/compose/v2/pkg/progress"
|
ui "github.com/docker/compose/v2/pkg/progress"
|
||||||
buildkit "github.com/moby/buildkit/util/progress/progressui"
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/docker/compose/v2/pkg/api"
|
"github.com/docker/compose/v2/pkg/api"
|
||||||
@ -137,7 +136,7 @@ func buildCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service)
|
|||||||
flags.Bool("no-rm", false, "Do not remove intermediate containers after a successful build. DEPRECATED")
|
flags.Bool("no-rm", false, "Do not remove intermediate containers after a successful build. DEPRECATED")
|
||||||
flags.MarkHidden("no-rm") //nolint:errcheck
|
flags.MarkHidden("no-rm") //nolint:errcheck
|
||||||
flags.VarP(&opts.memory, "memory", "m", "Set memory limit for the build container. Not supported by BuildKit.")
|
flags.VarP(&opts.memory, "memory", "m", "Set memory limit for the build container. Not supported by BuildKit.")
|
||||||
flags.StringVar(&p.Progress, "progress", string(buildkit.AutoMode), fmt.Sprintf(`Set type of ui output (%s)`, strings.Join(printerModes, ", ")))
|
flags.StringVar(&p.Progress, "progress", "", fmt.Sprintf(`Set type of ui output (%s)`, strings.Join(printerModes, ", ")))
|
||||||
flags.MarkHidden("progress") //nolint:errcheck
|
flags.MarkHidden("progress") //nolint:errcheck
|
||||||
flags.BoolVar(&opts.print, "print", false, "Print equivalent bake file")
|
flags.BoolVar(&opts.print, "print", false, "Print equivalent bake file")
|
||||||
flags.BoolVar(&opts.check, "check", false, "Check build configuration")
|
flags.BoolVar(&opts.check, "check", false, "Check build configuration")
|
||||||
|
@ -47,7 +47,6 @@ import (
|
|||||||
ui "github.com/docker/compose/v2/pkg/progress"
|
ui "github.com/docker/compose/v2/pkg/progress"
|
||||||
"github.com/docker/compose/v2/pkg/remote"
|
"github.com/docker/compose/v2/pkg/remote"
|
||||||
"github.com/docker/compose/v2/pkg/utils"
|
"github.com/docker/compose/v2/pkg/utils"
|
||||||
buildkit "github.com/moby/buildkit/util/progress/progressui"
|
|
||||||
"github.com/morikuni/aec"
|
"github.com/morikuni/aec"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@ -230,7 +229,7 @@ func (o *ProjectOptions) addProjectFlags(f *pflag.FlagSet) {
|
|||||||
f.StringVar(&o.ProjectDir, "project-directory", "", "Specify an alternate working directory\n(default: the path of the, first specified, Compose file)")
|
f.StringVar(&o.ProjectDir, "project-directory", "", "Specify an alternate working directory\n(default: the path of the, first specified, Compose file)")
|
||||||
f.StringVar(&o.WorkDir, "workdir", "", "DEPRECATED! USE --project-directory INSTEAD.\nSpecify an alternate working directory\n(default: the path of the, first specified, Compose file)")
|
f.StringVar(&o.WorkDir, "workdir", "", "DEPRECATED! USE --project-directory INSTEAD.\nSpecify an alternate working directory\n(default: the path of the, first specified, Compose file)")
|
||||||
f.BoolVar(&o.Compatibility, "compatibility", false, "Run compose in backward compatibility mode")
|
f.BoolVar(&o.Compatibility, "compatibility", false, "Run compose in backward compatibility mode")
|
||||||
f.StringVar(&o.Progress, "progress", defaultStringVar(ComposeProgress, string(buildkit.AutoMode)), fmt.Sprintf(`Set type of progress output (%s)`, strings.Join(printerModes, ", ")))
|
f.StringVar(&o.Progress, "progress", os.Getenv(ComposeProgress), fmt.Sprintf(`Set type of progress output (%s)`, strings.Join(printerModes, ", ")))
|
||||||
f.BoolVar(&o.All, "all-resources", false, "Include all resources, even those not used by services")
|
f.BoolVar(&o.All, "all-resources", false, "Include all resources, even those not used by services")
|
||||||
_ = f.MarkHidden("workdir")
|
_ = f.MarkHidden("workdir")
|
||||||
}
|
}
|
||||||
@ -242,14 +241,6 @@ func defaultStringArrayVar(env string) []string {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// get default value for a command line flag from the env variable, if the env variable is not set, it returns the provided default value 'def'
|
|
||||||
func defaultStringVar(env, def string) string {
|
|
||||||
if v, ok := os.LookupEnv(env); ok {
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
return def
|
|
||||||
}
|
|
||||||
|
|
||||||
func (o *ProjectOptions) projectOrName(ctx context.Context, dockerCli command.Cli, services ...string) (*types.Project, string, error) {
|
func (o *ProjectOptions) projectOrName(ctx context.Context, dockerCli command.Cli, services ...string) (*types.Project, string, error) {
|
||||||
name := o.ProjectName
|
name := o.ProjectName
|
||||||
var project *types.Project
|
var project *types.Project
|
||||||
@ -516,8 +507,7 @@ func RootCommand(dockerCli command.Cli, backend Backend) *cobra.Command { //noli
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch opts.Progress {
|
switch opts.Progress {
|
||||||
case ui.ModeAuto:
|
case "", ui.ModeAuto:
|
||||||
ui.Mode = ui.ModeAuto
|
|
||||||
if ansi == "never" {
|
if ansi == "never" {
|
||||||
ui.Mode = ui.ModePlain
|
ui.Mode = ui.ModePlain
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ Define and run multi-container applications with Docker
|
|||||||
| `-f`, `--file` | `stringArray` | | Compose configuration files |
|
| `-f`, `--file` | `stringArray` | | Compose configuration files |
|
||||||
| `--parallel` | `int` | `-1` | Control max parallelism, -1 for unlimited |
|
| `--parallel` | `int` | `-1` | Control max parallelism, -1 for unlimited |
|
||||||
| `--profile` | `stringArray` | | Specify a profile to enable |
|
| `--profile` | `stringArray` | | Specify a profile to enable |
|
||||||
| `--progress` | `string` | `auto` | Set type of progress output (auto, tty, plain, json, quiet) |
|
| `--progress` | `string` | | Set type of progress output (auto, tty, plain, json, quiet) |
|
||||||
| `--project-directory` | `string` | | Specify an alternate working directory<br>(default: the path of the, first specified, Compose file) |
|
| `--project-directory` | `string` | | Specify an alternate working directory<br>(default: the path of the, first specified, Compose file) |
|
||||||
| `-p`, `--project-name` | `string` | | Project name |
|
| `-p`, `--project-name` | `string` | | Project name |
|
||||||
|
|
||||||
|
@ -169,7 +169,6 @@ options:
|
|||||||
swarm: false
|
swarm: false
|
||||||
- option: progress
|
- option: progress
|
||||||
value_type: string
|
value_type: string
|
||||||
default_value: auto
|
|
||||||
description: Set type of progress output (auto, tty, plain, json, quiet)
|
description: Set type of progress output (auto, tty, plain, json, quiet)
|
||||||
deprecated: false
|
deprecated: false
|
||||||
hidden: false
|
hidden: false
|
||||||
|
@ -118,7 +118,6 @@ options:
|
|||||||
swarm: false
|
swarm: false
|
||||||
- option: progress
|
- option: progress
|
||||||
value_type: string
|
value_type: string
|
||||||
default_value: auto
|
|
||||||
description: Set type of ui output (auto, tty, plain, json, quiet)
|
description: Set type of ui output (auto, tty, plain, json, quiet)
|
||||||
deprecated: false
|
deprecated: false
|
||||||
hidden: true
|
hidden: true
|
||||||
|
@ -18,6 +18,7 @@ package progress
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
@ -121,29 +122,30 @@ func NewWriter(ctx context.Context, out *streams.Out, progressTitle string) (Wri
|
|||||||
if !ok {
|
if !ok {
|
||||||
dryRun = false
|
dryRun = false
|
||||||
}
|
}
|
||||||
if Mode == ModeQuiet {
|
switch Mode {
|
||||||
|
case ModeQuiet:
|
||||||
return quiet{}, nil
|
return quiet{}, nil
|
||||||
}
|
case ModeJSON:
|
||||||
|
|
||||||
tty := Mode == ModeTTY
|
|
||||||
if Mode == ModeAuto && isTerminal {
|
|
||||||
tty = true
|
|
||||||
}
|
|
||||||
if tty {
|
|
||||||
return newTTYWriter(out, dryRun, progressTitle)
|
|
||||||
}
|
|
||||||
if Mode == ModeJSON {
|
|
||||||
return &jsonWriter{
|
return &jsonWriter{
|
||||||
out: out,
|
out: out,
|
||||||
done: make(chan bool),
|
done: make(chan bool),
|
||||||
dryRun: dryRun,
|
dryRun: dryRun,
|
||||||
}, nil
|
}, nil
|
||||||
|
case ModeTTY:
|
||||||
|
return newTTYWriter(out, dryRun, progressTitle)
|
||||||
|
case ModeAuto, "":
|
||||||
|
if isTerminal {
|
||||||
|
return newTTYWriter(out, dryRun, progressTitle)
|
||||||
}
|
}
|
||||||
|
fallthrough
|
||||||
|
case ModePlain:
|
||||||
return &plainWriter{
|
return &plainWriter{
|
||||||
out: out,
|
out: out,
|
||||||
done: make(chan bool),
|
done: make(chan bool),
|
||||||
dryRun: dryRun,
|
dryRun: dryRun,
|
||||||
}, nil
|
}, nil
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("unknown progress mode: %s", Mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
func newTTYWriter(out io.Writer, dryRun bool, progressTitle string) (Writer, error) {
|
func newTTYWriter(out io.Writer, dryRun bool, progressTitle string) (Writer, error) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user