mirror of
https://github.com/docker/compose.git
synced 2025-07-05 04:44:26 +02:00
move watch from alpha to main command
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
This commit is contained in:
parent
421a6b0506
commit
6be5f3003a
@ -477,6 +477,7 @@ func RootCommand(dockerCli command.Cli, backend api.Service) *cobra.Command { //
|
|||||||
copyCommand(&opts, dockerCli, backend),
|
copyCommand(&opts, dockerCli, backend),
|
||||||
waitCommand(&opts, dockerCli, backend),
|
waitCommand(&opts, dockerCli, backend),
|
||||||
scaleCommand(&opts, dockerCli, backend),
|
scaleCommand(&opts, dockerCli, backend),
|
||||||
|
watchCommand(&opts, dockerCli, backend),
|
||||||
alphaCommand(&opts, dockerCli, backend),
|
alphaCommand(&opts, dockerCli, backend),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -19,12 +19,11 @@ package compose
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/docker/cli/cli/command"
|
"github.com/docker/cli/cli/command"
|
||||||
"github.com/docker/compose/v2/internal/locker"
|
"github.com/docker/compose/v2/internal/locker"
|
||||||
|
|
||||||
"github.com/docker/compose/v2/pkg/api"
|
"github.com/docker/compose/v2/pkg/api"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -43,11 +42,14 @@ func watchCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service)
|
|||||||
}
|
}
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "watch [SERVICE...]",
|
Use: "watch [SERVICE...]",
|
||||||
Short: "EXPERIMENTAL - Watch build context for service and rebuild/refresh containers when files are updated",
|
Short: "Watch build context for service and rebuild/refresh containers when files are updated",
|
||||||
PreRunE: Adapt(func(ctx context.Context, args []string) error {
|
PreRunE: Adapt(func(ctx context.Context, args []string) error {
|
||||||
return nil
|
return nil
|
||||||
}),
|
}),
|
||||||
RunE: Adapt(func(ctx context.Context, args []string) error {
|
RunE: AdaptCmd(func(ctx context.Context, cmd *cobra.Command, args []string) error {
|
||||||
|
if cmd.Parent().Name() == "alpha" {
|
||||||
|
logrus.Warn("watch command is now available as a top level command")
|
||||||
|
}
|
||||||
return runWatch(ctx, dockerCli, backend, watchOpts, buildOpts, args)
|
return runWatch(ctx, dockerCli, backend, watchOpts, buildOpts, args)
|
||||||
}),
|
}),
|
||||||
ValidArgsFunction: completeServiceNames(dockerCli, p),
|
ValidArgsFunction: completeServiceNames(dockerCli, p),
|
||||||
@ -59,7 +61,6 @@ func watchCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func runWatch(ctx context.Context, dockerCli command.Cli, backend api.Service, watchOpts watchOptions, buildOpts buildOptions, services []string) error {
|
func runWatch(ctx context.Context, dockerCli command.Cli, backend api.Service, watchOpts watchOptions, buildOpts buildOptions, services []string) error {
|
||||||
fmt.Fprintln(os.Stderr, "watch command is EXPERIMENTAL")
|
|
||||||
project, err := watchOpts.ToProject(dockerCli, nil)
|
project, err := watchOpts.ToProject(dockerCli, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -6,7 +6,7 @@ Define and run multi-container applications with Docker.
|
|||||||
### Subcommands
|
### Subcommands
|
||||||
|
|
||||||
| Name | Description |
|
| Name | Description |
|
||||||
|:--------------------------------|:------------------------------------------------------------------------|
|
|:--------------------------------|:--------------------------------------------------------------------------------------|
|
||||||
| [`build`](compose_build.md) | Build or rebuild services |
|
| [`build`](compose_build.md) | Build or rebuild services |
|
||||||
| [`config`](compose_config.md) | Parse, resolve and render compose file in canonical format |
|
| [`config`](compose_config.md) | Parse, resolve and render compose file in canonical format |
|
||||||
| [`cp`](compose_cp.md) | Copy files/folders between a service container and the local filesystem |
|
| [`cp`](compose_cp.md) | Copy files/folders between a service container and the local filesystem |
|
||||||
@ -34,6 +34,7 @@ Define and run multi-container applications with Docker.
|
|||||||
| [`up`](compose_up.md) | Create and start containers |
|
| [`up`](compose_up.md) | Create and start containers |
|
||||||
| [`version`](compose_version.md) | Show the Docker Compose version information |
|
| [`version`](compose_version.md) | Show the Docker Compose version information |
|
||||||
| [`wait`](compose_wait.md) | Block until the first service container stops |
|
| [`wait`](compose_wait.md) | Block until the first service container stops |
|
||||||
|
| [`watch`](compose_watch.md) | Watch build context for service and rebuild/refresh containers when files are updated |
|
||||||
|
|
||||||
|
|
||||||
### Options
|
### Options
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# docker compose alpha watch
|
# docker compose alpha watch
|
||||||
|
|
||||||
<!---MARKER_GEN_START-->
|
<!---MARKER_GEN_START-->
|
||||||
EXPERIMENTAL - Watch build context for service and rebuild/refresh containers when files are updated
|
Watch build context for service and rebuild/refresh containers when files are updated
|
||||||
|
|
||||||
### Options
|
### Options
|
||||||
|
|
||||||
|
16
docs/reference/compose_watch.md
Normal file
16
docs/reference/compose_watch.md
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
# docker compose watch
|
||||||
|
|
||||||
|
<!---MARKER_GEN_START-->
|
||||||
|
Watch build context for service and rebuild/refresh containers when files are updated
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
| Name | Type | Default | Description |
|
||||||
|
|:------------|:-----|:--------|:----------------------------------------------|
|
||||||
|
| `--dry-run` | | | Execute command in dry run mode |
|
||||||
|
| `--no-up` | | | Do not build & start services before watching |
|
||||||
|
| `--quiet` | | | hide build output |
|
||||||
|
|
||||||
|
|
||||||
|
<!---MARKER_GEN_END-->
|
||||||
|
|
@ -173,6 +173,7 @@ cname:
|
|||||||
- docker compose up
|
- docker compose up
|
||||||
- docker compose version
|
- docker compose version
|
||||||
- docker compose wait
|
- docker compose wait
|
||||||
|
- docker compose watch
|
||||||
clink:
|
clink:
|
||||||
- docker_compose_build.yaml
|
- docker_compose_build.yaml
|
||||||
- docker_compose_config.yaml
|
- docker_compose_config.yaml
|
||||||
@ -201,6 +202,7 @@ clink:
|
|||||||
- docker_compose_up.yaml
|
- docker_compose_up.yaml
|
||||||
- docker_compose_version.yaml
|
- docker_compose_version.yaml
|
||||||
- docker_compose_wait.yaml
|
- docker_compose_wait.yaml
|
||||||
|
- docker_compose_watch.yaml
|
||||||
options:
|
options:
|
||||||
- option: ansi
|
- option: ansi
|
||||||
value_type: string
|
value_type: string
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
command: docker compose alpha watch
|
command: docker compose alpha watch
|
||||||
short: |
|
short: |
|
||||||
EXPERIMENTAL - Watch build context for service and rebuild/refresh containers when files are updated
|
Watch build context for service and rebuild/refresh containers when files are updated
|
||||||
long: |
|
long: |
|
||||||
EXPERIMENTAL - Watch build context for service and rebuild/refresh containers when files are updated
|
Watch build context for service and rebuild/refresh containers when files are updated
|
||||||
usage: docker compose alpha watch [SERVICE...]
|
usage: docker compose alpha watch [SERVICE...]
|
||||||
pname: docker compose alpha
|
pname: docker compose alpha
|
||||||
plink: docker_compose_alpha.yaml
|
plink: docker_compose_alpha.yaml
|
||||||
|
47
docs/reference/docker_compose_watch.yaml
Normal file
47
docs/reference/docker_compose_watch.yaml
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
command: docker compose watch
|
||||||
|
short: |
|
||||||
|
Watch build context for service and rebuild/refresh containers when files are updated
|
||||||
|
long: |
|
||||||
|
Watch build context for service and rebuild/refresh containers when files are updated
|
||||||
|
usage: docker compose watch [SERVICE...]
|
||||||
|
pname: docker compose
|
||||||
|
plink: docker_compose.yaml
|
||||||
|
options:
|
||||||
|
- option: no-up
|
||||||
|
value_type: bool
|
||||||
|
default_value: "false"
|
||||||
|
description: Do not build & start services before watching
|
||||||
|
deprecated: false
|
||||||
|
hidden: false
|
||||||
|
experimental: false
|
||||||
|
experimentalcli: false
|
||||||
|
kubernetes: false
|
||||||
|
swarm: false
|
||||||
|
- option: quiet
|
||||||
|
value_type: bool
|
||||||
|
default_value: "false"
|
||||||
|
description: hide build output
|
||||||
|
deprecated: false
|
||||||
|
hidden: false
|
||||||
|
experimental: false
|
||||||
|
experimentalcli: false
|
||||||
|
kubernetes: false
|
||||||
|
swarm: false
|
||||||
|
inherited_options:
|
||||||
|
- option: dry-run
|
||||||
|
value_type: bool
|
||||||
|
default_value: "false"
|
||||||
|
description: Execute command in dry run mode
|
||||||
|
deprecated: false
|
||||||
|
hidden: false
|
||||||
|
experimental: false
|
||||||
|
experimentalcli: false
|
||||||
|
kubernetes: false
|
||||||
|
swarm: false
|
||||||
|
deprecated: false
|
||||||
|
hidden: false
|
||||||
|
experimental: false
|
||||||
|
experimentalcli: false
|
||||||
|
kubernetes: false
|
||||||
|
swarm: false
|
||||||
|
|
@ -89,7 +89,7 @@ func doTest(t *testing.T, svcName string, tarSync bool) {
|
|||||||
cleanup()
|
cleanup()
|
||||||
t.Cleanup(cleanup)
|
t.Cleanup(cleanup)
|
||||||
|
|
||||||
cmd := cli.NewDockerComposeCmd(t, "--verbose", "alpha", "watch", svcName)
|
cmd := cli.NewDockerComposeCmd(t, "--verbose", "watch", svcName)
|
||||||
// stream output since watch runs in the background
|
// stream output since watch runs in the background
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
|
Loading…
x
Reference in New Issue
Block a user