Deployment Guide
Overview
This guide covers deployment strategies for ReCloud across different environments, from development setups to enterprise production deployments.
Quick Deployment
Docker Deployment
# Start with Docker Compose
docker-compose up -d
# Access the application
# Desktop Application: Native desktop application
# Web Interface: http://localhost:8080
Development Setup
# Install dependencies
npm install
# Configure environment
cp .env.example .env
# Edit .env with your API keys
# Start development servers
npm start
Production Deployment
Infrastructure Requirements
Minimum Requirements
- CPU: 2 cores
- RAM: 4GB
- Storage: 20GB SSD
- Network: 100Mbps connection
Recommended Requirements
- CPU: 4+ cores
- RAM: 8GB+
- Storage: 50GB+ SSD
- Network: 1Gbps connection
Cloud Deployment Options
AWS Deployment
# AWS CloudFormation template
Resources:
ReCloudInstance:
Type: AWS::EC2::Instance
Properties:
InstanceType: t3.medium
ImageId: ami-12345678
SecurityGroups:
- !Ref ReCloudSecurityGroup
Google Cloud Platform
# GCP Deployment Manager
resources:
- name: recloud-instance
type: compute.v1.instance
properties:
zone: us-central1-a
machineType: https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-a/machineTypes/n1-standard-2
Azure Deployment
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"resources": [
{
"type": "Microsoft.Compute/virtualMachines",
"apiVersion": "2021-03-01",
"name": "recloud-vm",
"location": "[resourceGroup().location]",
"properties": {
"hardwareProfile": {
"vmSize": "Standard_DS2_v2"
}
}
}
]
}
Configuration Management
Environment Variables
# Core Configuration
NODE_ENV=production
PORT=3001
# AI Integration
GEMINI_API_KEY=your_production_key
# Security
JWT_SECRET=your_secure_secret
API_KEY_SALT=your_salt_value
# Database
DATABASE_URL=postgresql://user:pass@host:5432/recloud
# Caching
REDIS_URL=redis://localhost:6379
CACHE_TTL=3600
Configuration Files
// config/production.json
{
"server": {
"port": 3001,
"host": "0.0.0.0",
"cors": {
"origin": ["https://yourdomain.com"],
"credentials": true
}
},
"database": {
"type": "postgresql",
"host": "db.yourdomain.com",
"pool": {
"min": 5,
"max": 20
}
},
"monitoring": {
"enabled": true,
"metrics": {
"prometheus": true,
"datadog": false
}
}
}
Scaling Strategies
Horizontal Scaling
# Kubernetes deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: recloud-api
spec:
replicas: 3
selector:
matchLabels:
app: recloud-api
template:
metadata:
labels:
app: recloud-api
spec:
containers:
- name: api
image: recloud/api:latest
ports:
- containerPort: 3001
env:
- name: NODE_ENV
value: "production"
Load Balancing
# Nginx configuration
upstream recloud_backend {
server api1.yourdomain.com:3001;
server api2.yourdomain.com:3001;
server api3.yourdomain.com:3001;
}
server {
listen 80;
server_name api.yourdomain.com;
location / {
proxy_pass http://recloud_backend;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
Monitoring and Observability
Health Checks
// Health endpoint implementation
app.get('/health', async (req, res) => {
const health = {
status: 'healthy',
timestamp: new Date().toISOString(),
services: {
database: await checkDatabase(),
redis: await checkRedis(),
gemini_api: await checkGeminiAPI()
},
metrics: {
uptime: process.uptime(),
memory: process.memoryUsage(),
version: process.env.npm_package_version
}
};
const statusCode = health.services.database &&
health.services.redis &&
health.services.gemini_api ? 200 : 503;
res.status(statusCode).json(health);
});
Logging Configuration
// Logging setup
const logger = winston.createLogger({
level: process.env.LOG_LEVEL || 'info',
format: winston.format.combine(
winston.format.timestamp(),
winston.format.errors({ stack: true }),
winston.format.json()
),
transports: [
new winston.transports.File({ filename: 'logs/error.log', level: 'error' }),
new winston.transports.File({ filename: 'logs/combined.log' }),
new winston.transports.Console({
format: winston.format.simple()
})
]
});
Security Hardening
SSL/TLS Configuration
# SSL configuration for Nginx
server {
listen 443 ssl http2;
server_name api.yourdomain.com;
ssl_certificate /path/to/ssl/cert.pem;
ssl_certificate_key /path/to/ssl/private.key;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:...;
location / {
proxy_pass http://localhost:3001;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Firewall Configuration
# Firewall rules
ufw default deny incoming
ufw default allow outgoing
ufw allow ssh
ufw allow 80
ufw allow 443
ufw allow 3001
ufw --force enable
Backup and Recovery
Database Backup
# PostgreSQL backup script
#!/bin/bash
DATE=$(date +%Y%m%d_%H%M%S)
pg_dump -h localhost -U recloud_user recloud_db > backup_$DATE.sql
gzip backup_$DATE.sql
aws s3 cp backup_$DATE.sql.gz s3://recloud-backups/
Configuration Backup
# Configuration backup
# Create compressed backup of configuration files
Troubleshooting Deployment
Common Issues
Port Conflicts
# Check what's using port 3001
lsof -i :3001
# Kill process
kill -9 $(lsof -ti :3001)
Memory Issues
# Check memory usage
free -h
ps aux --sort=-%mem | head
# Increase Node.js memory limit
export NODE_OPTIONS="--max-old-space-size=4096"
Database Connection Issues
# Test database connection
psql -h localhost -U recloud_user -d recloud_db -c "SELECT 1;"
# Check PostgreSQL logs
# Review database log files
Performance Optimization
Caching Strategies
// Redis caching setup
import { createClient } from 'redis';
const redisClient = createClient({
url: process.env.REDIS_URL
});
redisClient.on('error', (err) => console.log('Redis Client Error', err));
// Cache wrapper
export async function cacheWrapper<T>(
key: string,
ttl: number,
fn: () => Promise<T>
): Promise<T> {
const cached = await redisClient.get(key);
if (cached) {
return JSON.parse(cached);
}
const result = await fn();
await redisClient.setEx(key, ttl, JSON.stringify(result));
return result;
}
Database Optimization
-- Database indexes for performance
CREATE INDEX idx_tool_executions_tool_name ON tool_executions(tool_name);
CREATE INDEX idx_tool_executions_user_id ON tool_executions(user_id);
CREATE INDEX idx_tool_executions_created_at ON tool_executions(created_at DESC);
-- Partitioning for large tables
CREATE TABLE tool_executions_y2024m01 PARTITION OF tool_executions
FOR VALUES FROM ('2024-01-01') TO ('2024-02-01');
This deployment guide provides comprehensive instructions for production-ready ReCloud installations with enterprise-grade reliability, security, and performance.