API Status v2.4.1

Deploying Your Application

This guide covers the end-to-end process of deploying applications to CloudNexus infrastructure. Learn how to configure your project, deploy via CLI or API, and manage environments.

â„šī¸
Prerequisites: Ensure you have the cnx CLI installed and authenticated. If not, follow our Installation Guide.

Project Setup

Before deploying, initialize a CloudNexus project in your repository root. This creates a cnx.json configuration file.

Bash
cnx init

The command will prompt you for:

Configuration File

Your cnx.json file controls deployment behavior:

JSON
{
  "name": "my-app",
  "runtime": "node-20",
  "build": "npm run build",
  "start": "npm start",
  "regions": ["us-east-1", "eu-west-1"],
  "replicas": 3,
  "env": {
    "NODE_ENV": "production",
    "PORT": 3000
  }
}

Deploy Command

Deploy your application using the deploy command. By default, it deploys to the production environment.

Bash
cnx deploy --env production
âš ī¸
Zero-Downtime: CloudNexus performs blue-green deployments by default. Traffic switches only after health checks pass.

Deployment Flags

Flag Description Default
--env Target environment name production
--region Override region from config Config value
--wait Wait for deployment to complete true
--dry-run Validate without deploying false

Docker Deployments

For containerized applications, set runtime: docker and provide a Dockerfile.

JSON
{
  "runtime": "docker",
  "dockerfilePath": "./Dockerfile",
  "resources": {
    "cpu": "2 vCPU",
    "memory": "4GB"
  }
}

Deploying via API

Use the REST API for CI/CD pipelines or programmatic deployments.

HTTP
POST /v1/projects/{projectId}/deployments
Authorization: Bearer ${CNX_TOKEN}
Content-Type: application/json

{
  "gitProvider": "github",
  "repo": "owner/repo",
  "branch": "main",
  "env": "production"
}

Verifying Deployment

After deployment, verify status using the CLI or dashboard.

Bash
cnx status --env production

# Output:
# ✓ Environment: production
# ✓ Region: us-east-1
# ✓ Replicas: 3/3 healthy
# ✓ URL: https://my-app.cloudnexus.app
✅
Success: Your application is now live. SSL certificates are provisioned automatically.

Troubleshooting

Common deployment issues and solutions: