Skip to main content

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

ParameterDescriptionRequired
-e, --env-id <envId>Environment IDNo
-s, --serviceName <serviceName>Service nameNo
--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 URLNo
--imageUrl <imageUrl>Image URL for image-based deployment of Cloud Run service (e.g., ccr.ccs.tencentyun.com/ns/img:v1)No
--createAgentCreate a function-based Agent and simultaneously deploy dependent function-type Cloud Run serviceNo
--forceForce deployment and skip all confirmation promptsNo
--installDependency <installDependency>Install dependencies online. Available values: true | falseNo
--trafficEnable 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-runDry run to validate code loading and configuration without actually deployingNo
-h, --helpShow command help informationNo

Precautions

  • Ensure that the code has passed local testing before deployment.
  • For container services, the --port parameter must be specified; for function services, it does not need to be specified.
  • Use --source to deploy code from a non-current directory.
  • It is recommended to use tcb cloudrun run for local testing first.
  • Cloud Run code project sample: nodejs_hello_world