Examples
Real-world TurboCI configuration examples for common deployment scenarios.
Next.js Application with Load Balancer
A production Next.js app with multiple instances and load balancing.
- deployment_name: nextjs_prod
provider: hetzner
location: ash
description: Production Next.js deployment
services:
web:
instances: 2
clusters: 2
server_type: cpx21
dir_mappings:
- src: .
dst: /app
- src: ./secrets/prod.env
dst: /app/.env
dependencies:
apt:
- rsync
turboci:
- bun
- node
run:
preflight:
work_dir: /app
cmds:
- bun add -g pm2
- pm2 kill
- bun install
- bunx next build
start:
work_dir: /app
cmds:
- pm2 start "bunx next start"
postflight:
cmds:
- pm2 list
healthcheck:
cmd: curl http://localhost:3000/api/healthcheck
test: Server Running
load_balancer:
type: load_balancer
target_services:
- service_name: web
port: 3000
Multi-Cloud Deployment
Deploy the same application to multiple cloud providers using deployment duplication.
- deployment_name: web_hetzner
provider: hetzner
location: ash
services:
web:
instances: 2
clusters: 2
server_type: cpx21
dir_mappings:
- src: .
dst: /app
run:
start:
work_dir: /app
cmds:
- npm start
- deployment_name: web_aws
provider: aws
location: us-east-1
duplicate_deployment_name: web_hetzner
- deployment_name: web_gcp
provider: gcp
location: us-central1
duplicate_deployment_name: web_hetzner
Load Balancer with SSL
Configure a load balancer with multiple target services and SSL certificates.
services:
web_prod:
instances: 5
clusters: 2
server_type: cpx21
# ... other config
web_dev:
instances: 2
clusters: 1
server_type: cpx11
# ... other config
load_balancer:
type: load_balancer
target_services:
- service_name: web_prod
port: 3000
domains:
- example.com
- www.example.com
- service_name: web_dev
port: 3000
domains:
- dev.example.com
ssl:
email: admin@example.com
Docker Service
Deploy a Docker-based service with automatic Docker installation.
services:
app:
type: docker
instances: 3
clusters: 2
server_type: cpx21
dir_mappings:
- src: .
dst: /app
dependencies:
turboci:
- docker
run:
start:
work_dir: /app
cmds:
- docker-compose up -d
Service Duplication
Reuse service configurations with the duplicate_service_name field.
services:
web_prod:
instances: 10
clusters: 3
server_type: cpx31
dir_mappings:
- src: .
dst: /app
dependencies:
turboci:
- node
run:
start:
work_dir: /app
cmds:
- npm start
env:
- NODE_ENV=production
web_staging:
duplicate_service_name: web_prod
instances: 2
clusters: 1
server_type: cpx11
env:
- NODE_ENV=staging