Add --build
option to compose run
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
This commit is contained in:
parent
754376916c
commit
35d31cc500
@ -113,6 +113,7 @@ func runCommand(p *projectOptions, dockerCli command.Cli, backend api.Service) *
|
|||||||
projectOptions: p,
|
projectOptions: p,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
createOpts := createOptions{}
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "run [OPTIONS] SERVICE [COMMAND] [ARGS...]",
|
Use: "run [OPTIONS] SERVICE [COMMAND] [ARGS...]",
|
||||||
Short: "Run a one-off command on a service.",
|
Short: "Run a one-off command on a service.",
|
||||||
@ -141,7 +142,7 @@ func runCommand(p *projectOptions, dockerCli command.Cli, backend api.Service) *
|
|||||||
}
|
}
|
||||||
ignore := project.Environment["COMPOSE_IGNORE_ORPHANS"]
|
ignore := project.Environment["COMPOSE_IGNORE_ORPHANS"]
|
||||||
opts.ignoreOrphans = strings.ToLower(ignore) == "true"
|
opts.ignoreOrphans = strings.ToLower(ignore) == "true"
|
||||||
return runRun(ctx, backend, project, opts)
|
return runRun(ctx, backend, project, opts, createOpts)
|
||||||
}),
|
}),
|
||||||
ValidArgsFunction: completeServiceNames(p),
|
ValidArgsFunction: completeServiceNames(p),
|
||||||
}
|
}
|
||||||
@ -161,6 +162,7 @@ func runCommand(p *projectOptions, dockerCli command.Cli, backend api.Service) *
|
|||||||
flags.BoolVar(&opts.useAliases, "use-aliases", false, "Use the service's network useAliases in the network(s) the container connects to.")
|
flags.BoolVar(&opts.useAliases, "use-aliases", false, "Use the service's network useAliases in the network(s) the container connects to.")
|
||||||
flags.BoolVar(&opts.servicePorts, "service-ports", false, "Run command with the service's ports enabled and mapped to the host.")
|
flags.BoolVar(&opts.servicePorts, "service-ports", false, "Run command with the service's ports enabled and mapped to the host.")
|
||||||
flags.BoolVar(&opts.quietPull, "quiet-pull", false, "Pull without printing progress information.")
|
flags.BoolVar(&opts.quietPull, "quiet-pull", false, "Pull without printing progress information.")
|
||||||
|
flags.BoolVar(&createOpts.Build, "build", false, "Build image before starting container.")
|
||||||
|
|
||||||
cmd.Flags().BoolVarP(&opts.interactive, "interactive", "i", true, "Keep STDIN open even if not attached.")
|
cmd.Flags().BoolVarP(&opts.interactive, "interactive", "i", true, "Keep STDIN open even if not attached.")
|
||||||
cmd.Flags().BoolP("tty", "t", true, "Allocate a pseudo-TTY.")
|
cmd.Flags().BoolP("tty", "t", true, "Allocate a pseudo-TTY.")
|
||||||
@ -181,12 +183,14 @@ func normalizeRunFlags(f *pflag.FlagSet, name string) pflag.NormalizedName {
|
|||||||
return pflag.NormalizedName(name)
|
return pflag.NormalizedName(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
func runRun(ctx context.Context, backend api.Service, project *types.Project, opts runOptions) error {
|
func runRun(ctx context.Context, backend api.Service, project *types.Project, opts runOptions, createOpts createOptions) error {
|
||||||
err := opts.apply(project)
|
err := opts.apply(project)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
createOpts.Apply(project)
|
||||||
|
|
||||||
err = progress.Run(ctx, func(ctx context.Context) error {
|
err = progress.Run(ctx, func(ctx context.Context) error {
|
||||||
return startDependencies(ctx, backend, *project, opts.Service, opts.ignoreOrphans)
|
return startDependencies(ctx, backend, *project, opts.Service, opts.ignoreOrphans)
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user