Code Deployment
Using the deploy command, you can deploy local project code to the Cloud Run environment.
Basic Usage
tcb cloudrun deploy
Usage Example:
# Interactive deployment. The CLI will guide you through selecting services and environments.
tcb cloudrun deploy
# Deploy the code in the current directory to the specified service
tcb cloudrun deploy -e env-123456 -s my-service
# Deploy container-based services and specify the port
tcb cloudrun deploy -e env-123456 -s api-service --port 8080
# Deploy the code in the specified directory
tcb cloudrun deploy -e env-123456 -s my-service --source ./dist
# Force deployment and skip confirmation prompts
tcb cloudrun deploy -e env-123456 -s my-service --force
# Deploy using an image URL
tcb cloudrun deploy -e env-123456 -s my-service --imageUrl ccr.ccs.tencentyun.com/ns/img:v1
# Deploy with VPC network 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"}'
Create and Deploy an Agent
tcb cloudrun deploy -e <envId> --createAgent
Usage Example:
# Create a function-based Agent and deploy dependent function services
tcb cloudrun deploy -e env-123456 --createAgent
# Create an Agent and force deployment
tcb cloudrun deploy -e env-123456 --createAgent --force
Command Line Parameters
| Parameter | Description | Required |
|---|---|---|
-e, --env-id <envId> | Environment ID | No |
-s, --serviceName <serviceName> | Service name | No |
--port <port> | Container service port (invalid for function-type Cloud Run) | No |
--source <source> | Path to the directory containing the deployment code (absolute or relative path, default: current directory). Can be omitted when deploying with an image URL | No |
--imageUrl <imageUrl> | Image URL for image-based deployment of Cloud Run service (e.g., ccr.ccs.tencentyun.com/ns/img:v1) | No |
--createAgent | Create a function-based Agent and simultaneously deploy dependent function-type Cloud Run service | No |
--force | Force deployment and skip all confirmation prompts | No |
--installDependency <installDependency> | Install dependencies online. Available values: true | false | No |
--traffic | Enable canary deployment (manual traffic switch required after successful deployment) | No |
--vpcConfig <vpcConfig> | VPC network configuration in JSON format. Must include four fields: vpcId, vpcCIDR, subnetId, subnetCIDR. Example:--vpcConfig '{"vpcId":"vpc-xxx","vpcCIDR":"10.0.0.0/16","subnetId":"subnet-xxx","subnetCIDR":"10.0.1.0/24"}' | No |
--dry-run | Dry run to validate code loading and configuration without actually deploying | No |
-h, --help | Show command help information | No |
Precautions
- Ensure that the code has passed local testing before deployment.
- For container services, the
--portparameter must be specified; for function services, it does not need to be specified. - Use
--sourceto deploy code from a non-current directory. - It is recommended to use
tcb cloudrun runfor local testing first. - Cloud Run code project sample: nodejs_hello_world