This guide covers deploying SocialAi to production environments.
- Node 24+ Requirements
- Pre-Deployment Checklist
- Vercel Deployment (Frontend)
- Backend Deployment Options
- Desktop Admin Distribution
- Deployment Options
- VPS Deployment
- Docker Deployment
- Cloud Platform Deployment
- Database Setup
- Environment Configuration
- SSL/TLS Setup
- Monitoring & Logging
- Backup & Recovery
- Scaling
- Maintenance
- Rollback Procedure
SocialAi requires Node.js 24 or higher for all components.
- Modern JavaScript features
- Performance improvements
- Enhanced security
- Long-term support
node --version # Should output v24.x.x or higherVerified Platforms with Node 24+ Support:
- ✅ Vercel (default for frontend)
- ✅ Railway
- ✅ Render
- ✅ Fly.io
- ✅ AWS EC2/ECS
- ✅ Google Cloud Run
- ✅ Azure App Service
- ✅ DigitalOcean App Platform
Not Recommended:
- ❌ Platforms that don't support Node 24+
- ❌ Platform tiers or providers where Node 24+ runtimes are not available
Before deploying to production:
- Confirm Node.js 24+ on target platform
- Test build with Node 24+
- Update
.nvmrcif needed (default: 24.13.0)
- Change all default passwords
- Generate strong JWT secret
- Configure CORS for production domains
- Enable HTTPS/TLS
- Set up firewall rules
- Disable debug logging
- Review and update
.envfile - Scan for vulnerabilities (
npm audit)
- Set
NODE_ENV=production - Configure production database
- Set up external service APIs (Farcaster, OpenAI, etc.)
- Configure rate limiting
- Set up CDN for static assets (optional)
- Configure email service (optional)
- Run full test suite
- Test production build locally
- Verify all environment variables
- Test database migrations
- Verify external API connectivity
- Build optimized bundles
- Minify assets
- Enable compression
- Set up caching headers
- Optimize database queries
- Add database indexes
The public frontend app is optimized for Vercel with Node.js 24 runtime.
-
Connect Repository:
- Go to vercel.com
- Import your GitHub repository
- Select the
SocialAiproject
-
Configure Build Settings:
Framework Preset: Astro Build Command: npm run build:public Output Directory: apps/public/dist Install Command: npm install --legacy-peer-deps Node Version: 24.x -
Set Environment Variables:
PUBLIC_API_URL=your_backend_api_url NODE_ENV=production -
Deploy:
- Click "Deploy"
- Vercel will automatically build and deploy
# Install Vercel CLI
npm install -g vercel
# Login
vercel login
# Deploy
vercel
# Deploy to production
vercel --prodThe vercel.json file is already configured with:
- Node.js 24 runtime
- Optimized build settings
- Correct output directory
- Production-ready deployment settings for the Astro frontend
Important: Before deploying to Vercel, update apps/public/astro.config.mjs to use the @astrojs/vercel adapter:
import vercel from '@astrojs/vercel/serverless';
export default defineConfig({
output: 'server',
adapter: vercel(), // Use vercel adapter for Vercel deployment
// ... rest of config
});The @astrojs/vercel package is already installed. Simply uncomment the vercel adapter line and comment out the node adapter in the config file before deploying to Vercel.
- Go to Project Settings → Domains
- Add your custom domain
- Follow DNS configuration instructions
- SSL is automatically provisioned
Configure in Vercel Dashboard (frontend only):
- Project Settings → Environment Variables
- Add only the
PUBLIC_API_URLvariable - Set its value to the public base URL of your backend API (e.g. your Railway/Render backend URL)
- Select environment (Production, Preview, Development)
- Save
Important:
- Do not add backend secrets from
.env.example(e.g.DATABASE_URL,JWT_SECRET,SESSION_SECRET) to the Vercel frontend project. - Configure backend-only secrets only in your backend deployment environment (Railway, Render, etc.).
- Never commit secrets to the repository. Always use your platform's environment variable system.
The backend requires Node.js 24+ and can be deployed to various platforms.
Railway provides managed PostgreSQL and supports Node.js 24+.
- Install Railway CLI:
npm install -g @railway/cli- Login and Deploy:
railway login
railway init
railway up- Configure:
- Add PostgreSQL service
- Set environment variables
- Deploy backend
- Create new Web Service on render.com
- Connect repository
- Configure:
Build Command: npm install Start Command: npm run dev Node Version: 24 - Add environment variables
- Deploy
- Install Fly CLI
- Create
fly.toml:
app = "socialai-backend"
[build]
[build.env]
NODE_VERSION = "24"
[env]
PORT = "3000"
[[services]]
internal_port = 3000
protocol = "tcp"- Deploy:
fly deploy
The Windows desktop admin app can be distributed to users.
On a Windows machine with Node 24+ and Rust:
npm run build:desktop:windowsThis creates:
admin.msi- MSI installeradmin-setup.exe- NSIS installer
Located in: desktop-admin/src-tauri/target/release/bundle/
- Direct Download: Host installer files on your server
- GitHub Releases: Upload as release assets
- Microsoft Store: Submit for distribution (requires developer account)
For Tauri 2.x, auto-updates for the desktop admin app must be configured using the Tauri 2 updater system (either via bundle.updater in desktop-admin/src-tauri/tauri.conf.json or the official updater plugin).
Refer to the official Tauri 2 documentation for the exact configuration format and recommended update distribution setup: https://tauri.app/v2/guides/distribution/updater/
Best for: Full control, custom configuration Examples: DigitalOcean, Linode, AWS EC2 Cost: $5-50/month
Best for: Easy deployment, managed infrastructure Examples: Heroku, Render, Railway Cost: $7-25/month
Best for: Scalability, portability Examples: AWS ECS, Google Cloud Run, Azure Container Apps Cost: $10-100/month
Best for: Variable traffic, pay-per-use Examples: Vercel, Netlify, AWS Lambda Cost: $0-50/month (usage-based)
- Ubuntu 22.04 LTS server
- Root or sudo access
- Domain name pointing to server IP
# Update system
sudo apt update && sudo apt upgrade -y
# Create deploy user
sudo adduser deploy
sudo usermod -aG sudo deploy
# Setup firewall
sudo ufw allow OpenSSH
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable
# Switch to deploy user
su - deploy# Install Node.js 24.x
curl -fsSL https://deb.nodesource.com/setup_24.x | sudo -E bash -
sudo apt-get install -y nodejs
# Install PostgreSQL 14
sudo apt-get install -y postgresql postgresql-contrib
# Install Nginx
sudo apt-get install -y nginx
# Install certbot for SSL
sudo apt-get install -y certbot python3-certbot-nginx
# Install PM2 for process management
sudo npm install -g pm2# Switch to postgres user
sudo -u postgres psql
# Create database and user
CREATE DATABASE socialai;
CREATE USER socialai WITH ENCRYPTED PASSWORD 'your_secure_password';
GRANT ALL PRIVILEGES ON DATABASE socialai TO socialai;
\q
# Run schema
psql -U socialai -d socialai -f /path/to/db/schema.sql# Clone repository
cd /home/deploy
git clone https://github.com/SMSDAO/SocialAi.git
cd SocialAi
# Install dependencies
npm install
# Build frontend apps
cd apps/public
npm install
npm run build
cd ../admin
npm install
npm run build
# Configure environment
cd /home/deploy/SocialAi
cp .env.example .env
nano .env # Edit with production values# Create ecosystem file
cat > ecosystem.config.js << EOF
module.exports = {
apps: [{
name: 'socialai-backend',
script: './node/socialai.node.js',
instances: 2,
exec_mode: 'cluster',
env: {
NODE_ENV: 'production',
PORT: 3000
}
}]
};
EOF
# Start application
pm2 start ecosystem.config.js
# Setup PM2 to start on boot
pm2 startup
pm2 save# Create Nginx configuration
sudo nano /etc/nginx/sites-available/socialai
# Add this configuration:
server {
listen 80;
server_name yourdomain.com www.yourdomain.com;
# Backend API
location /api {
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;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# Health endpoint
location /health {
proxy_pass http://localhost:3000;
}
# Admin console (static files)
location /admin {
alias /home/deploy/SocialAi/apps/admin/dist;
try_files $uri $uri/ /admin/index.html;
}
# Public app (SSR)
location / {
proxy_pass http://localhost:4321;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
# Enable site
sudo ln -s /etc/nginx/sites-available/socialai /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx# Get SSL certificate
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com
# Auto-renewal is configured by certbot
# Test renewal
sudo certbot renew --dry-run# Check backend
curl https://yourdomain.com/health
# Check PM2 status
pm2 status
# Check Nginx status
sudo systemctl status nginx
# Check logs
pm2 logsNote: Docker is not the recommended deployment method for this project. The production-ready approach uses Vercel for the frontend and Railway/Render for the backend. However, if you need Docker, update all base images to Node 24:
# Dockerfile.backend
FROM node:24-alpine
WORKDIR /app
# Copy package files
COPY package*.json ./
COPY node/package*.json ./node/
COPY workers/package*.json ./workers/
# Install dependencies
RUN npm install --production
# Copy application files
COPY node/ ./node/
COPY workers/ ./workers/
COPY db/ ./db/
WORKDIR /app/node
EXPOSE 3000
CMD ["node", "socialai.node.js"]# Dockerfile.public
FROM node:24-alpine
WORKDIR /app
# Copy package files
COPY apps/public/package*.json ./
# Install dependencies
RUN npm install
# Copy application files
COPY apps/public/ ./
# Build
RUN npm run build
EXPOSE 4321
CMD ["node", "dist/server/entry.mjs"]# Dockerfile.admin
FROM node:24-alpine as build
WORKDIR /app
# Copy package files
COPY apps/admin/package*.json ./
# Install dependencies
RUN npm install
# Copy application files
COPY apps/admin/ ./
# Build
RUN npm run build
# Production stage
FROM nginx:alpine
COPY --from=build /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/nginx.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]version: '3.8'
services:
db:
image: postgres:14-alpine
environment:
POSTGRES_DB: socialai
POSTGRES_USER: socialai
POSTGRES_PASSWORD: ${DB_PASSWORD}
volumes:
- postgres_data:/var/lib/postgresql/data
- ./db/schema.sql:/docker-entrypoint-initdb.d/schema.sql
ports:
- "5432:5432"
restart: unless-stopped
backend:
build:
context: .
dockerfile: Dockerfile.backend
environment:
NODE_ENV: production
DATABASE_URL: postgresql://socialai:${DB_PASSWORD}@db:5432/socialai
JWT_SECRET: ${JWT_SECRET}
PORT: 3000
ports:
- "3000:3000"
depends_on:
- db
restart: unless-stopped
public:
build:
context: .
dockerfile: Dockerfile.public
environment:
API_URL: http://backend:3000
ports:
- "4321:4321"
depends_on:
- backend
restart: unless-stopped
admin:
build:
context: .
dockerfile: Dockerfile.admin
ports:
- "80:80"
depends_on:
- backend
restart: unless-stopped
volumes:
postgres_data:# Create .env file
cat > .env << EOF
DB_PASSWORD=your_secure_password
JWT_SECRET=your_jwt_secret
EOF
# Build and start services
docker-compose up -d
# View logs
docker-compose logs -f
# Check status
docker-compose ps
# Stop services
docker-compose down# Install Heroku CLI
curl https://cli-assets.heroku.com/install.sh | sh
# Login
heroku login
# Create app
heroku create socialai-app
# Add PostgreSQL addon
heroku addons:create heroku-postgresql:mini
# Set environment variables
heroku config:set NODE_ENV=production
heroku config:set JWT_SECRET=your_secret
# Deploy
git push heroku main
# Run migrations
heroku run psql $DATABASE_URL < db/schema.sql
# View logs
heroku logs --tail- Connect GitHub repository
- Add PostgreSQL service
- Configure environment variables
- Deploy automatically on push
- Connect GitHub repository
- Create PostgreSQL database
- Create web service
- Set environment variables
- Deploy
# Tune PostgreSQL for production
sudo nano /etc/postgresql/14/main/postgresql.conf
# Recommended settings:
shared_buffers = 256MB
effective_cache_size = 1GB
maintenance_work_mem = 64MB
checkpoint_completion_target = 0.9
wal_buffers = 16MB
default_statistics_target = 100
random_page_cost = 1.1
effective_io_concurrency = 200
work_mem = 4MB
min_wal_size = 1GB
max_wal_size = 4GB
max_worker_processes = 4
max_parallel_workers_per_gather = 2
max_parallel_workers = 4# Manual backup
pg_dump -U socialai socialai > backup_$(date +%Y%m%d_%H%M%S).sql
# Automated daily backups
cat > /home/deploy/backup.sh << 'EOF'
#!/bin/bash
BACKUP_DIR="/home/deploy/backups"
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
pg_dump -U socialai socialai > "$BACKUP_DIR/socialai_$TIMESTAMP.sql"
# Keep only last 7 days
find "$BACKUP_DIR" -name "socialai_*.sql" -mtime +7 -delete
EOF
chmod +x /home/deploy/backup.sh
# Add to crontab
crontab -e
# Add: 0 2 * * * /home/deploy/backup.sh# Restore from backup
psql -U socialai socialai < backup_20240128_020000.sql# Node Environment
NODE_ENV=production
# Database
DATABASE_URL=postgresql://socialai:secure_password@localhost:5432/socialai
# Server
PORT=3000
CORS_ORIGIN=https://yourdomain.com
# Security
JWT_SECRET=very_long_random_string_at_least_64_characters_long
SESSION_SECRET=another_long_random_string
# Feature Flags
FARCASTER_SYNC_ENABLED=true
REDDIT_SYNC_ENABLED=false
AI_SUMMARIES_ENABLED=true
AI_RECOMMENDATIONS_ENABLED=true
# External Services
FARCASTER_HUB_URL=https://hub.farcaster.xyz
OPENAI_API_KEY=sk-your-production-key
# Rate Limiting
RATE_LIMIT_WINDOW_MS=60000
RATE_LIMIT_MAX_REQUESTS=100
# Logging
LOG_LEVEL=info# Install certbot
sudo apt-get install certbot python3-certbot-nginx
# Get certificate
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com
# Verify auto-renewal
sudo certbot renew --dry-run# Generate private key
openssl genrsa -out private.key 2048
# Generate CSR
openssl req -new -key private.key -out request.csr
# Purchase SSL certificate and install
sudo cp certificate.crt /etc/ssl/certs/
sudo cp private.key /etc/ssl/private/
# Configure Nginx
sudo nano /etc/nginx/sites-available/socialai
# Add SSL configuration:
listen 443 ssl;
ssl_certificate /etc/ssl/certs/certificate.crt;
ssl_certificate_key /etc/ssl/private/private.key;# PM2 Monitoring
pm2 monit
# PM2 Web Interface
pm2 install pm2-server-monit# View PM2 logs
pm2 logs
# View Nginx logs
sudo tail -f /var/log/nginx/access.log
sudo tail -f /var/log/nginx/error.log
# View PostgreSQL logs
sudo tail -f /var/log/postgresql/postgresql-14-main.logConsider integrating:
- Sentry - Error tracking
- LogRocket - Session replay
- New Relic - APM monitoring
Setup monitoring with:
- UptimeRobot - Free uptime monitoring
- Pingdom - Website monitoring
- StatusCake - Uptime and performance
-
Database Backups:
- Daily full backups
- Keep 7 days locally
- Upload to S3/Cloud Storage
-
Application Backups:
- Version controlled via Git
- Tagged releases
-
Environment Backups:
- Encrypted
.envbackups - Secure storage
- Encrypted
-
Regular Testing:
- Test backups monthly
- Document restore procedures
- Time recovery process
-
Failover Strategy:
- Secondary server (optional)
- Database replication
- DNS failover
Upgrade server resources:
- More RAM
- More CPU cores
- Faster storage (SSD)
# Nginx load balancer
upstream backend {
least_conn;
server backend1.yourdomain.com:3000;
server backend2.yourdomain.com:3000;
server backend3.yourdomain.com:3000;
}
server {
location /api {
proxy_pass http://backend;
}
}# Setup read replicas
# Primary database: writes
# Replica databases: reads
# Configure in application:
const primaryDB = new Pool({ host: 'primary.db' });
const replicaDB = new Pool({ host: 'replica.db' });
// Use replica for reads
const users = await replicaDB.query('SELECT * FROM users');
// Use primary for writes
await primaryDB.query('INSERT INTO users ...');# Install Redis
sudo apt-get install redis-server
# Use in application
const redis = require('redis');
const client = redis.createClient();
// Cache API responses
const cached = await client.get(key);
if (cached) return JSON.parse(cached);
const data = await fetchData();
await client.setex(key, 3600, JSON.stringify(data));Daily:
- Check application logs
- Monitor error rates
- Verify backups completed
Weekly:
- Review performance metrics
- Check disk space
- Update dependencies (security patches)
Monthly:
- Test backup restore
- Review and optimize database
- Update documentation
- Security audit
If deployment fails:
# Stop application
pm2 stop all
# Restore previous version
git checkout previous-tag
npm install
npm run build
# Restore database (if needed)
psql -U socialai socialai < backup_before_deployment.sql
# Restart application
pm2 restart allLast Updated: 2026-02-07