Deploy Your First Application
Learn how to configure, build, and deploy a production-ready application on CloudNexus in under 5 minutes.
Prerequisites
Before you begin, ensure you have the following installed and configured:
- Node.js 18.0 or later (LTS recommended)
- npm or pnpm package manager
- A valid CloudNexus account with billing enabled
- Basic familiarity with terminal commands
1. Generate API Keys
The CLI requires authentication via personal access tokens with appropriate scopes.
- Navigate to Dashboard → API & Keys
- Click "Generate New Token"
- Assign the following scopes:
deploy:write,env:read,logs:read - Copy the token immediately. It won't be shown again.
2. Install the CloudNexus CLI
Install the official CLI globally using your preferred package manager:
# Using npm
npm install -g @cloudnexus/cli
# Verify installation
cnx --version
Alternatively, use Homebrew on macOS/Linux:
brew tap cloudnexus/tap
brew install cnx
3. Initialize & Authenticate
Log in to your account and scaffold a new project:
# Authenticate with your API token
cnx auth login --token cnx_sk_your_generated_token_here
# Create a new project directory
cnx init my-production-app
# Navigate into the project
cd my-production-app
The CLI will generate a cnx.config.js file with sensible defaults for your runtime.
4. Configure Environment
Edit cnx.config.js to match your deployment requirements:
module.exports = {
name: 'my-production-app',
runtime: 'nodejs18',
region: 'us-east-1',
env: {
NODE_ENV: 'production',
DB_HOST: 'process.env.DB_HOST',
API_KEY: 'secret.ref.api_key_v1'
},
scaling: {
min: 2,
max: 20,
targetCpu: 65
},
healthCheck: '/api/health'
};
cnx secrets set to store sensitive values securely. They are never stored in plaintext config files.5. Deploy to Production
Push your code and trigger the build pipeline:
# Build and deploy with zero-downtime rollout
cnx deploy --prod
# Monitor deployment in real-time
cnx logs follow
The CLI will:
- Bundle your application with native optimization
- Provision compute instances in your selected region
- Run health checks before routing traffic
- Enable automatic rollbacks on failure
6. Verify & Monitor
After deployment, validate your endpoint and configure monitoring:
# Get deployment URL
cnx apps info
# Test health endpoint
curl https://my-app.cnx.app/api/health
# Open real-time metrics dashboard
cnx monitor open
Troubleshooting
Common Issues
- "Authentication failed": Ensure your token hasn't expired. Run
cnx auth refresh. - "Build timed out": Check
cnx.config.jsbuildCommand. Node 18+ requires explicit build scripts. - "Health check failing": Verify your app responds with 2xx to the
healthCheckpath.
For advanced debugging, run with verbose logging: cnx deploy --debug