> ## Documentation Index
> Fetch the complete documentation index at: https://docs.controlplane.com/llms.txt
> Use this file to discover all available pages before exploring further.

# stack

> cpln stack — Manage docker-compose files and deploy multi-service stacks to Control Plane.

manage docker-compose files

Refer to the [Compose Deploy guide](https://docs.controlplane.com/guides/compose-deploy.md) for additional details.

```none theme={null}
cpln stack [SUBCOMMAND]
```

```text theme={null}
Commands:
  cpln stack deploy    deploy from a docker-compose file  [aliases: up]
  cpln stack manifest  Generate a CPLN apply file from a docker-compose file
  cpln stack rm        Delete objects from a docker-compose file  [aliases: down]

Options:
  --help  Show help  [boolean]
```

***

#### stack deploy

deploy from a docker-compose file

Refer to the [compose deploy guide](https://docs.controlplane.com/guides/compose-deploy.md) for more details.

**Usage**

```none theme={null}
cpln stack deploy [OPTIONS]
```

> [!NOTE]
>
> * Variables such as `${VERSION}` are substituted from the environment and the `.env` file next to the compose file, or from the files given with `--env-file`. A service that names its image next to `build`, such as `image: api:${VERSION}`, is built and pushed to your org's registry under that name and tag. Pass `--no-interpolate` to keep every value as written.
> * A service's `env_file` loads each listed file into its containers, a later file overriding an earlier one and `environment` overriding them all. Unlike `.env`, a listed file must exist, or the command stops before building or deploying anything. Give the entry `required: false` in the long syntax to skip it while it is missing.
> * Services deploy in `depends_on` order. A dependency waited for with `service_healthy` must become ready, and one waited for with `service_completed_successfully` runs once as a job, before the services that need it are applied. `--wait-timeout` sets how long each wait lasts. Pass `--no-deps` to apply every workload at once.

> [accordion] Reference
>
> ```text theme={null}
> Command options:
>   --directory, --dir  Path to parent folder of docker-compose file
>   --compose-file      Name of the docker-compose file if alternative naming was used
>   --build             Build images  [boolean] [default: true]
>   --interpolate       Substitute the variables the compose file references, such as ${VERSION}, from the environment and the .env file, as docker compose does. Use --no-interpolate to keep them as written  [boolean] [default: true]
>   --env-file          Read the variables to substitute from this file instead of the .env file next to the compose file. Give it more than once to layer files, a later file winning
>   --deps              Honor depends_on: a service that another waits for with service_completed_successfully becomes a job, and stack deploy runs it and follows the dependency order. Use --no-deps to ignore depends_on  [boolean] [default: true]
>   --wait-timeout      Seconds to wait for each depends_on condition: a workload becoming ready, or a job completing  [number] [default: 600]
>
> Context options:
>   --profile  Override the profile. The default profile can be set using the `cpln profile set-default` command or by setting the CPLN_PROFILE environment variable
>   --org      Override the organization. The default organization can be set in your profile by using the `cpln profile update` command
>   --gvc      Override the global virtual cloud. The default global virtual cloud can be set in your profile by using the `cpln profile update` command
>
> Options:
>   --help  Show help  [boolean]
> ```
>
> [Common Options Reference](https://docs.controlplane.com/cli-reference/using-cli/common-options.md)

> [accordion] Example
>
> * Assuming there is a docker compose project in the current directory
>
> ```bash Command theme={null}
> cpln stack deploy
> ```
>
> ```text Output theme={null}
> Created /org/demo-cpln-organization/secret/demo-secret
> Created /org/demo-cpln-organization/gvc/demo-cpln-gvc/identity/demo-identity
> Created /org/demo-cpln-organization/gvc/demo-cpln-gvc/volumeset/demo-volume
> Created /org/demo-cpln-organization/gvc/demo-cpln-gvc/workload/demo-workload
> Created /org/demo-cpln-organization/policy/demo-policy
> ```
>
> * Assuming the compose project in the current directory has `api` wait for `migrations` with `service_completed_successfully`, and `migrations` wait for `database` with `service_healthy`
>
> ```bash Command theme={null}
> cpln stack deploy
> ```
>
> ```text Output theme={null}
> Created /org/demo-cpln-organization/gvc/demo-cpln-gvc/workload/migrations
> Created /org/demo-cpln-organization/gvc/demo-cpln-gvc/workload/api
> Created /org/demo-cpln-organization/gvc/demo-cpln-gvc/workload/database
> Updated workload 'migrations'
> Completed job 'migrations' in location 'aws-us-west-2'
> Updated workload 'api'
> ```

***

#### stack manifest

Generate a CPLN spec file from a compose project and print it to stdout. With `--build`, it also builds the images and pushes them to your org's registry.

**Usage**

```none theme={null}
cpln stack manifest [OPTIONS]
```

> [!NOTE]
>
> A service waited for with `service_completed_successfully` converts to a cron workload that runs only when started. A manifest cannot carry the order: `cpln apply` creates every workload at once and starts no job. Use [cpln stack deploy](#stack-deploy) for an ordered deploy, or start the job yourself with `cpln workload cron start NAME --location LOCATION`. Pass `--no-deps` to ignore `depends_on`.

> [accordion] Reference
>
> ```text theme={null}
> Command options:
>   --directory, --dir  Path to parent folder of docker-compose file
>   --compose-file      Name of the docker-compose file if alternative naming was used
>   --build             Build images  [boolean] [default: false]
>   --interpolate       Substitute the variables the compose file references, such as ${VERSION}, from the environment and the .env file, as docker compose does. Use --no-interpolate to keep them as written  [boolean] [default: true]
>   --env-file          Read the variables to substitute from this file instead of the .env file next to the compose file. Give it more than once to layer files, a later file winning
>   --deps              Honor depends_on: a service that another waits for with service_completed_successfully becomes a job, and stack deploy runs it and follows the dependency order. Use --no-deps to ignore depends_on  [boolean] [default: true]
>
> Context options:
>   --profile  Override the profile. The default profile can be set using the `cpln profile set-default` command or by setting the CPLN_PROFILE environment variable
>   --org      Override the organization. The default organization can be set in your profile by using the `cpln profile update` command
>   --gvc      Override the global virtual cloud. The default global virtual cloud can be set in your profile by using the `cpln profile update` command
>
> Format options:
>   --output, -o  Set the output format  [choices: "text", "json", "yaml", "json-slim", "yaml-slim", "tf", "crd", "names"]
>   --color       Colorize the output  [boolean] [default: true]
>   --ts          Timestamp format if the output format is text (e.g., --output=text)  [choices: "iso", "local", "age"]
>   --max         Maximum number of records to show. A value less than 1 will return all records.  [number] [default: 50]
>
> Options:
>   --help  Show help  [boolean]
> ```
>
> [Common Options Reference](https://docs.controlplane.com/cli-reference/using-cli/common-options.md)

> [accordion] Example
>
> * Assuming there is a docker compose project in the current directory.
>
> ```bash Command theme={null}
> cpln stack manifest
> ```
>
> ```yaml Output theme={null}
> kind: secret
> name: demo-secret
> description: demo-secret
> type: opaque
> data:
>   encoding: plain
>   payload: demo secret
> ---
> kind: identity
> name: demo-identity
> description: Identity to allow demo-workload to reveal secret
> ---
> kind: volumeset
> name: demo-volume
> description: demo-volume
> spec:
>   fileSystemType: ext4
>   initialCapacity: 10
>   performanceClass: general-purpose-ssd
> ---
> kind: workload
> name: demo-workload
> description: demo-workload
> spec:
>   type: standard
>   containers:
>     - name: demo-workload-container
>       cpu: 250m
>       memory: 53Mi
>       ports:
>         - number: 3000
>       image: demo-image:1.0
>       volumes:
>         - path: /secrets/secret.txt
>           uri: 'cpln://secret/demo-secret'
>           recoveryPolicy: retain
>   defaultOptions:
>     capacityAI: false
>   identityLink: /org/demo-cpln-organization/gvc/demo-cpln-gvc/identity/demo-identity
>   firewallConfig:
>     external:
>       inboundAllowCIDR:
>         - 0.0.0.0/0
>       outboundAllowCIDR:
>         - 0.0.0.0/0
> ---
> kind: policy
> name: demo-policy
> description: Policy for workloads to reveal demo-secret
> bindings:
>   - permissions:
>       - reveal
>     principalLinks:
>       - /org/demo-cpln-organization/gvc/demo-cpln-gvc/identity/demo-identity
> targetKind: secret
> targetLinks:
>   - /org/demo-cpln-organization/secret/demo-secret
> ```

***

#### stack rm

Delete all resources generated from a docker compose project.

**Usage**

```none theme={null}
cpln stack rm [OPTIONS]
```

> [!NOTE]
>
> If the compose file references variables, for example `image: api:${VERSION}` next to `build`, set the same variables and pass the same `--env-file` options you deployed with. Resource names never come from variables, so the same resources are removed either way.

> [accordion] Reference
>
> ```text theme={null}
> Command options:
>   --directory, --dir  Path to parent folder of docker-compose file
>   --compose-file      Name of the docker-compose file if alternative naming was used
>   --interpolate       Substitute the variables the compose file references, such as ${VERSION}, from the environment and the .env file, as docker compose does. Use --no-interpolate to keep them as written  [boolean] [default: true]
>   --env-file          Read the variables to substitute from this file instead of the .env file next to the compose file. Give it more than once to layer files, a later file winning
>
> Context options:
>   --profile  Override the profile. The default profile can be set using the `cpln profile set-default` command or by setting the CPLN_PROFILE environment variable
>   --org      Override the organization. The default organization can be set in your profile by using the `cpln profile update` command
>   --gvc      Override the global virtual cloud. The default global virtual cloud can be set in your profile by using the `cpln profile update` command
>
> Options:
>   --help  Show help  [boolean]
> ```
>
> [Common Options Reference](https://docs.controlplane.com/cli-reference/using-cli/common-options.md)

> [accordion] Example
>
> * Assuming there is a docker compose project in the current directory
>
> ```bash Command theme={null}
> cpln stack rm
> ```
>
> ```text Output theme={null}
> Deleted /org/demo-cpln-organization/secret/demo-secret
> Deleted /org/demo-cpln-organization/gvc/demo-cpln-gvc/identity/demo-identity
> Deleted /org/demo-cpln-organization/gvc/demo-cpln-gvc/volumeset/demo-volume
> Deleted /org/demo-cpln-organization/gvc/demo-cpln-gvc/workload/demo-workload
> Deleted /org/demo-cpln-organization/policy/demo-policy
> ```

***
