mirror of https://github.com/docker/compose.git
Merge pull request #730 from aiordache/ecs_detached_up
Add detach flag to `compose up`
This commit is contained in:
commit
005c6dcfe7
|
@ -44,7 +44,7 @@ func newComposeService(ctx store.AciContext) aciComposeService {
|
|||
}
|
||||
}
|
||||
|
||||
func (cs *aciComposeService) Up(ctx context.Context, project *types.Project) error {
|
||||
func (cs *aciComposeService) Up(ctx context.Context, project *types.Project, detach bool) error {
|
||||
logrus.Debugf("Up on project with name %q", project.Name)
|
||||
groupDefinition, err := convert.ToContainerGroup(ctx, cs.ctx, *project, cs.storageLogin)
|
||||
addTag(&groupDefinition, composeContainerTag)
|
||||
|
|
|
@ -30,7 +30,7 @@ type composeService struct {
|
|||
}
|
||||
|
||||
// Up executes the equivalent to a `compose up`
|
||||
func (c *composeService) Up(context.Context, *types.Project) error {
|
||||
func (c *composeService) Up(context.Context, *types.Project, bool) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ import (
|
|||
// Service manages a compose project
|
||||
type Service interface {
|
||||
// Up executes the equivalent to a `compose up`
|
||||
Up(ctx context.Context, project *types.Project) error
|
||||
Up(ctx context.Context, project *types.Project, detach bool) error
|
||||
// Down executes the equivalent to a `compose down`
|
||||
Down(ctx context.Context, projectName string) error
|
||||
// Logs executes the equivalent to a `compose logs`
|
||||
|
|
|
@ -34,6 +34,7 @@ type composeOptions struct {
|
|||
ConfigPaths []string
|
||||
Environment []string
|
||||
Format string
|
||||
Detach bool
|
||||
}
|
||||
|
||||
func (o *composeOptions) toProjectName() (string, error) {
|
||||
|
|
|
@ -40,7 +40,7 @@ func upCommand(contextType string) *cobra.Command {
|
|||
upCmd.Flags().StringVar(&opts.WorkingDir, "workdir", "", "Work dir")
|
||||
upCmd.Flags().StringArrayVarP(&opts.ConfigPaths, "file", "f", []string{}, "Compose configuration files")
|
||||
upCmd.Flags().StringArrayVarP(&opts.Environment, "environment", "e", []string{}, "Environment variables")
|
||||
upCmd.Flags().BoolP("detach", "d", true, " Detached mode: Run containers in the background")
|
||||
upCmd.Flags().BoolVarP(&opts.Detach, "detach", "d", false, " Detached mode: Run containers in the background")
|
||||
|
||||
if contextType == store.AciContextType {
|
||||
upCmd.Flags().StringVar(&opts.DomainName, "domainname", "", "Container NIS domain name")
|
||||
|
@ -68,8 +68,7 @@ func runUp(ctx context.Context, opts composeOptions) error {
|
|||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return "", c.ComposeService().Up(ctx, project)
|
||||
return "", c.ComposeService().Up(ctx, project, opts.Detach)
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ import (
|
|||
"golang.org/x/mod/semver"
|
||||
)
|
||||
|
||||
func (e ecsLocalSimulation) Up(ctx context.Context, project *types.Project) error {
|
||||
func (e ecsLocalSimulation) Up(ctx context.Context, project *types.Project, detach bool) error {
|
||||
cmd := exec.Command("docker-compose", "version", "--short")
|
||||
b := bytes.Buffer{}
|
||||
b.WriteString("v")
|
||||
|
|
|
@ -26,7 +26,7 @@ import (
|
|||
"github.com/compose-spec/compose-go/types"
|
||||
)
|
||||
|
||||
func (b *ecsAPIService) Up(ctx context.Context, project *types.Project) error {
|
||||
func (b *ecsAPIService) Up(ctx context.Context, project *types.Project, detach bool) error {
|
||||
err := b.SDK.CheckRequirements(ctx, b.Region)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -58,7 +58,9 @@ func (b *ecsAPIService) Up(ctx context.Context, project *types.Project) error {
|
|||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if detach {
|
||||
return nil
|
||||
}
|
||||
signalChan := make(chan os.Signal, 1)
|
||||
signal.Notify(signalChan, syscall.SIGINT, syscall.SIGTERM)
|
||||
go func() {
|
||||
|
|
|
@ -131,7 +131,7 @@ func (cs *containerService) Delete(ctx context.Context, id string, request conta
|
|||
|
||||
type composeService struct{}
|
||||
|
||||
func (cs *composeService) Up(ctx context.Context, project *types.Project) error {
|
||||
func (cs *composeService) Up(ctx context.Context, project *types.Project, detach bool) error {
|
||||
fmt.Printf("Up command on project %q", project.Name)
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue