Deployment
Megabyte Island runs natively on Node.js β no Docker required.
1. Build
# Build backend
cd backend && npm run build
# Build frontend
cd ../frontend && npm run build Outputs: backend/dist/ and frontend/build/.
2. Process management with PM2
Install PM2 globally:
npm install -g pm2 Create ecosystem.config.js in the project root:
module.exports = {
apps: [
{
name: 'gaas-backend',
script: './backend/dist/index.js',
env: { NODE_ENV: 'production' },
instances: 2,
exec_mode: 'cluster',
max_memory_restart: '512M',
},
{
name: 'gaas-frontend',
script: './frontend/build/index.js',
env: { NODE_ENV: 'production', PORT: '3000' },
},
],
}; Start and save:
pm2 start ecosystem.config.js
pm2 save
pm2 startup # follow the printed instructions 3. NGINX reverse proxy
server {
listen 80;
server_name agents.megabyteisland.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
server_name agents.megabyteisland.com;
ssl_certificate /etc/letsencrypt/live/agents.megabyteisland.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/agents.megabyteisland.com/privkey.pem;
# Frontend (SvelteKit)
location / {
proxy_pass http://127.0.0.1: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;
}
# Backend API + Webhooks
location ~ ^/(api|webhooks|health) {
proxy_pass http://127.0.0.1:3001;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
# Required for SSE streaming (chat proxy)
proxy_buffering off;
proxy_cache off;
proxy_read_timeout 300s;
}
} 4. TLS with Letβs Encrypt
apt install certbot python3-certbot-nginx
certbot --nginx -d agents.megabyteisland.com 5. Environment variables in production
Do not use .env files in production. Set variables directly in the system environment or use a secrets manager:
[Service]
Environment="NODE_ENV=production"
Environment="PORT=3001"
# ... other vars 6. Health monitoring
Check service status:
pm2 status
pm2 logs gaas-backend --lines 50 Set up an uptime monitor (e.g., Better Uptime, UptimeRobot) pointing to:
GET https://agents.megabyteisland.com/health Expected response: {"status":"ok",...}