When to use this
Installcpln in a container image for:
- CI/CD jobs - Run
cplncommands in containerized pipelines - Cron Workloads - Execute automation tasks in Control Plane cron workloads
- Custom automation images - Bundle
cplnwith your tools and scripts
Installation methods
- npm (Node.js base)
- Binary (lightweight)
Use this method if your base image already includes Node.js (16 or later).Build and run:Exec into the container:Test the CLI:Cleanup:
Dockerfile
bash
bash
bash
bash
Pin the CLI version
Always pin the CLI version for reproducible builds:- npm: https://www.npmjs.com/package/@controlplane/cli
- Binary: See Installation
Runtime authentication
Pass secrets via environment variables
Set at minimumCPLN_TOKEN when running the container:
Using cpln in automation
Once installed, execute CLI commands from your application code:- Node.js
- Python
- Go
- Bash
Common workflows
Build and push images
This runs the build through a Docker daemon inside the container. For containers without one, see CI/CD Usage.
Apply resources
Execute workload commands
Troubleshooting
cpln: not found
cpln: not found
Verify the binary is in PATH and executable:Ensure the binary is copied to a directory in PATH (e.g.,
/usr/local/bin).Authentication failures
Authentication failures
-
Verify
CPLN_TOKENis set at runtime: - Check the token isn’t truncated
Docker registry authentication issues
Docker registry authentication issues
Re-run Docker login in your container:Ensure the service account has access to the image registry.
For more troubleshooting help, see the Troubleshooting page.
Best practices
Use multi-stage builds
Use multi-stage builds
Keep final images small by using multi-stage builds to separate download/build tools from the runtime image.
Pin the CLI version
Pin the CLI version
Always specify an exact CLI version for reproducible builds:
Never bake credentials
Never bake credentials
Pass tokens at runtime via environment variables or secret managers. Never include them in the image.
Set CPLN_ORG and CPLN_GVC
Set CPLN_ORG and CPLN_GVC
Set
CPLN_ORG and CPLN_GVC as environment variables so you don’t need to pass --org and --gvc flags with every command:Verify installation in Dockerfile
Verify installation in Dockerfile
Add a verification step:This catches installation issues during the build.
Next steps
CI/CD Usage
Complete CI/CD automation guide
Installation
CLI installation methods
Authentication
Authentication strategies
Profiles
Profile management