mirror of
https://github.com/docker/compose.git
synced 2025-07-19 11:44:26 +02:00
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)
|
logrus.Debugf("Up on project with name %q", project.Name)
|
||||||
groupDefinition, err := convert.ToContainerGroup(ctx, cs.ctx, *project, cs.storageLogin)
|
groupDefinition, err := convert.ToContainerGroup(ctx, cs.ctx, *project, cs.storageLogin)
|
||||||
addTag(&groupDefinition, composeContainerTag)
|
addTag(&groupDefinition, composeContainerTag)
|
||||||
|
@ -30,7 +30,7 @@ type composeService struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Up executes the equivalent to a `compose up`
|
// 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
|
return errdefs.ErrNotImplemented
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ import (
|
|||||||
// Service manages a compose project
|
// Service manages a compose project
|
||||||
type Service interface {
|
type Service interface {
|
||||||
// Up executes the equivalent to a `compose up`
|
// 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 executes the equivalent to a `compose down`
|
||||||
Down(ctx context.Context, projectName string) error
|
Down(ctx context.Context, projectName string) error
|
||||||
// Logs executes the equivalent to a `compose logs`
|
// Logs executes the equivalent to a `compose logs`
|
||||||
|
@ -34,6 +34,7 @@ type composeOptions struct {
|
|||||||
ConfigPaths []string
|
ConfigPaths []string
|
||||||
Environment []string
|
Environment []string
|
||||||
Format string
|
Format string
|
||||||
|
Detach bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *composeOptions) toProjectName() (string, error) {
|
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().StringVar(&opts.WorkingDir, "workdir", "", "Work dir")
|
||||||
upCmd.Flags().StringArrayVarP(&opts.ConfigPaths, "file", "f", []string{}, "Compose configuration files")
|
upCmd.Flags().StringArrayVarP(&opts.ConfigPaths, "file", "f", []string{}, "Compose configuration files")
|
||||||
upCmd.Flags().StringArrayVarP(&opts.Environment, "environment", "e", []string{}, "Environment variables")
|
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 {
|
if contextType == store.AciContextType {
|
||||||
upCmd.Flags().StringVar(&opts.DomainName, "domainname", "", "Container NIS domain name")
|
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 {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
return "", c.ComposeService().Up(ctx, project, opts.Detach)
|
||||||
return "", c.ComposeService().Up(ctx, project)
|
|
||||||
})
|
})
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ import (
|
|||||||
"golang.org/x/mod/semver"
|
"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")
|
cmd := exec.Command("docker-compose", "version", "--short")
|
||||||
b := bytes.Buffer{}
|
b := bytes.Buffer{}
|
||||||
b.WriteString("v")
|
b.WriteString("v")
|
||||||
|
@ -26,7 +26,7 @@ import (
|
|||||||
"github.com/compose-spec/compose-go/types"
|
"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)
|
err := b.SDK.CheckRequirements(ctx, b.Region)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -58,7 +58,9 @@ func (b *ecsAPIService) Up(ctx context.Context, project *types.Project) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if detach {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
signalChan := make(chan os.Signal, 1)
|
signalChan := make(chan os.Signal, 1)
|
||||||
signal.Notify(signalChan, syscall.SIGINT, syscall.SIGTERM)
|
signal.Notify(signalChan, syscall.SIGINT, syscall.SIGTERM)
|
||||||
go func() {
|
go func() {
|
||||||
|
@ -131,7 +131,7 @@ func (cs *containerService) Delete(ctx context.Context, id string, request conta
|
|||||||
|
|
||||||
type composeService struct{}
|
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)
|
fmt.Printf("Up command on project %q", project.Name)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user