Deploy a Project
Learn how to deploy your OrionOS agent to production environments.
Deployment Options
OrionOS supports multiple deployment platforms:
Cloud Platforms: Vercel, Railway, Render, AWS, Google Cloud
Containerized: Docker, Kubernetes
Serverless: AWS Lambda, Google Cloud Functions
VPS: DigitalOcean, Linode, Vultr
Pre-Deployment Checklist
Before deploying, ensure:
Quick Deploy with Vercel
1. Prepare Your Project
# Build your project
pnpm build
# Test production build locally
pnpm start2. Deploy to Vercel
# Install Vercel CLI
npm install -g vercel
# Deploy
vercel deploy
# Deploy to production
vercel --prod3. Configure Environment Variables
In Vercel dashboard:
Go to Project Settings → Environment Variables
Add all required keys from your
.envfileRedeploy
Deploy with Railway
1. Install Railway CLI
npm install -g @railway/cli2. Initialize Railway
railway login
railway init3. Deploy
railway up4. Set Environment Variables
railway variables set OPENAI_API_KEY=your_key
railway variables set DISCORD_BOT_TOKEN=your_tokenDocker Deployment
1. Create Dockerfile
FROM node:20-alpine
WORKDIR /app
# Copy package files
COPY package*.json ./
RUN npm install --production
# Copy application files
COPY . .
# Build the application
RUN npm run build
# Expose port
EXPOSE 3000
# Start the agent
CMD ["npm", "start"]2. Build Image
docker build -t orion-agent .3. Run Container
docker run -d \
--name my-orion-agent \
-e OPENAI_API_KEY=your_key \
-e DISCORD_BOT_TOKEN=your_token \
-p 3000:3000 \
orion-agent4. Docker Compose
Create docker-compose.yml:
version: '3.8'
services:
agent:
build: .
environment:
- OPENAI_API_KEY=${OPENAI_API_KEY}
- DISCORD_BOT_TOKEN=${DISCORD_BOT_TOKEN}
ports:
- "3000:3000"
restart: unless-stopped
volumes:
- ./data:/app/data
postgres:
image: postgres:15
environment:
- POSTGRES_DB=orionos
- POSTGRES_USER=orion
- POSTGRES_PASSWORD=${DB_PASSWORD}
volumes:
- postgres_data:/var/lib/postgresql/data
volumes:
postgres_data:Run with:
docker-compose up -dAWS Deployment
Using EC2
Launch EC2 Instance
Choose Ubuntu 22.04 LTS
t3.small or larger recommended
Configure security groups (ports 22, 80, 443)
Connect and Setup
# SSH into instance
ssh -i your-key.pem ubuntu@your-instance-ip
# Update system
sudo apt update && sudo apt upgrade -y
# Install Node.js
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs
# Install PM2
sudo npm install -g pm2
# Clone and setup your project
git clone your-repo
cd your-project
npm install
npm run buildStart with PM2
# Start agent
pm2 start npm --name "orion-agent" -- start
# Save PM2 configuration
pm2 save
# Setup startup script
pm2 startupUsing ECS (Container Service)
Build and Push Image
# Authenticate with ECR
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin your-account.dkr.ecr.us-east-1.amazonaws.com
# Build and tag
docker build -t orion-agent .
docker tag orion-agent:latest your-account.dkr.ecr.us-east-1.amazonaws.com/orion-agent:latest
# Push
docker push your-account.dkr.ecr.us-east-1.amazonaws.com/orion-agent:latestCreate ECS Task Definition
Deploy to ECS Cluster
Environment Variables Management
Using dotenv-vault
# Install
npm install -g dotenv-vault
# Login
npx dotenv-vault login
# Push environment
npx dotenv-vault push
# Pull on server
npx dotenv-vault pullUsing AWS Secrets Manager
// Load secrets in your app
import { SecretsManagerClient, GetSecretValueCommand } from "@aws-sdk/client-secrets-manager";
async function loadSecrets() {
const client = new SecretsManagerClient({ region: "us-east-1" });
const response = await client.send(
new GetSecretValueCommand({ SecretId: "orion-agent-secrets" })
);
return JSON.parse(response.SecretString);
}Monitoring and Logging
Setup Logging
// orion.config.js
export default {
logging: {
level: 'info',
file: './logs/agent.log',
maxSize: '10m',
maxFiles: 5
}
}PM2 Monitoring
# View logs
pm2 logs orion-agent
# Monitor
pm2 monit
# Web dashboard
pm2 plusUsing External Services
Sentry for Error Tracking:
npm install @sentry/node
# In your code
import * as Sentry from "@sentry/node";
Sentry.init({
dsn: process.env.SENTRY_DSN,
environment: process.env.NODE_ENV
});DataDog for Metrics:
npm install dd-trace
# At app entry
import tracer from 'dd-trace';
tracer.init({
service: 'orion-agent',
env: process.env.NODE_ENV
});SSL/HTTPS Setup
Using Let's Encrypt
# Install Certbot
sudo apt install certbot
# Get certificate
sudo certbot certonly --standalone -d your-domain.com
# Setup nginx reverse proxy
sudo apt install nginxNginx Configuration
server {
listen 80;
server_name your-domain.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
server_name your-domain.com;
ssl_certificate /etc/letsencrypt/live/your-domain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/your-domain.com/privkey.pem;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}Scaling
Horizontal Scaling
Run multiple instances:
# PM2 cluster mode
pm2 start npm --name "orion-agent" -i max -- startLoad Balancing
Use nginx for load balancing:
upstream orion_agents {
server localhost:3000;
server localhost:3001;
server localhost:3002;
}
server {
listen 80;
location / {
proxy_pass http://orion_agents;
}
}Backup and Recovery
Database Backups
# Automated PostgreSQL backups
#!/bin/bash
DATE=$(date +%Y%m%d_%H%M%S)
pg_dump orionos > backup_$DATE.sql
aws s3 cp backup_$DATE.sql s3://your-backup-bucket/Character File Backups
Keep character files in version control and backup regularly.
Troubleshooting
Common Issues
Agent not starting:
# Check logs
pm2 logs orion-agent --lines 100
# Verify environment variables
pm2 env orion-agentHigh memory usage:
# Restart with memory limit
pm2 start npm --name "orion-agent" --max-memory-restart 1G -- startConnection timeouts:
Check firewall rules
Verify security group settings
Test network connectivity
Deployment Best Practices
Use CI/CD: Automate deployments with GitHub Actions
Health Checks: Implement health check endpoints
Gradual Rollouts: Deploy to staging first
Monitoring: Set up alerts for critical issues
Backups: Regular automated backups
Documentation: Maintain deployment runbooks
Next Steps
Support
Need help with deployment?
Last updated

