tcb cloudrun deploy
Publish local project code or an image to a CloudBase Run service.
Usage
tcb cloudrun deploy [options]
Parameters
| Parameter | Required | Description | Default |
|---|---|---|---|
-e, --env-id <envId> | No | Environment ID | — |
-s, --serviceName <serviceName> | No | Service name | — |
--port <port> | No | Port of a container-type service, ignored for function-type services | — |
--source <source> | No | Code directory, resolved against the current directory; optional for image deployments | Project directory |
--imageUrl <imageUrl> | No | Image address, for example ccr.ccs.tencentyun.com/ns/img:v1 | — |
--createAgent | No | Create a function-type Agent and deploy the function-type services it depends on | false |
--force | No | Skip every confirmation prompt | false |
--yes | No | Confirm the pre-deploy prompt, useful in CI/CD | false |
--installDependency <bool> | No | Install dependencies online, true / false | — |
--traffic | No | Canary deployment, traffic must be switched manually after publish | false |
--min-num <minNum> | No | Minimum replica count, non-negative integer | — |
--max-num <maxNum> | No | Maximum replica count, non-negative integer | — |
--open-access-types <types> | No | Access policy types, comma-separated: OA / PUBLIC / MINIAPP / VPC | — |
--vpcConfig <json> | No | VPC network configuration JSON with vpcId, vpcCIDR, subnetId, subnetCIDR | — |
--wait | No | Block until the deployment finishes, polling every 3 seconds for up to 30 minutes; cannot be combined with --traffic | false |
--env-params <json> | No | Environment variables as JSON (v3.8.9+), values must be strings; replaces the whole set on an existing service | — |
--dry-run | No | Validate code loading and configuration without deploying | false |
Examples
# Interactive deployment, the CLI asks for service and environment
tcb cloudrun deploy
# Deploy the current directory to a specific service
tcb cloudrun deploy -e env-123456 -s my-service
# Deploy a container-type service with a port
tcb cloudrun deploy -e env-123456 -s api-service --port 8080
# Deploy code from a specific directory
tcb cloudrun deploy -e env-123456 -s my-service --source ./dist
# Deploy without confirmation
tcb cloudrun deploy -e env-123456 -s my-service --force
# Deploy from an image
tcb cloudrun deploy -e env-123456 -s my-service --imageUrl ccr.ccs.tencentyun.com/ns/img:v1 --port 3000
# Deploy with a VPC configuration
tcb cloudrun deploy -e env-123456 -s my-service --vpcConfig '{"vpcId":"vpc-xxx","vpcCIDR":"10.0.0.0/16","subnetId":"subnet-xxx","subnetCIDR":"10.0.1.0/24"}'
# Wait for the deployment, useful in CI/CD
tcb cloudrun deploy -e env-123456 -s my-service --force --yes --wait
Create an Agent and deploy
# Create a function-type Agent and deploy the services it depends on
tcb cloudrun deploy -e env-123456 --createAgent
# Create an Agent and force the deployment
tcb cloudrun deploy -e env-123456 --createAgent --force
Environment variables
--env-params takes a JSON string whose values must be strings; {"PORT":8080} is rejected:
tcb cloudrun deploy -e env-123456 -s my-service --env-params '{"NODE_ENV":"production","REDIS_HOST":"10.0.0.10"}'
The value replaces the whole set rather than merging by key:
| Input | Result |
|---|---|
--env-params '{"A":"1"}' | Online variables become {"A":"1"}, every other variable is removed |
--env-params omitted | Online variables stay unchanged |
--env-params '{}' | Online variables are cleared |
To change a single variable, pass the others along. Variables are submitted with the deployment, so a change only takes effect after redeploying.
Notes
- Code deployment uploads a package of the
--sourcedirectory and lets the platform build the image, which is pushed to the TCR Personal Edition instance under your account (Guangzhou region). The image is not kept locally and is not pushed to your own repository; to own the image, build and push it yourself and deploy with--image-url - Container-type services need
--port, function-type services do not - Verify the code locally with
tcb cloudrun runfirst - Sample project: nodejs_hello_world
Related Commands
- Traffic management: canary releases
- List deployment records
- Run locally