Deployment Guide
Deployment Guide
Section titled “Deployment Guide”Deploying ION Flow - Complete guide for deploying to production.
Overview
Section titled “Overview”ION Flow can be deployed as:
- Standalone Backend - Full application with WebSocket support
- Server Microservice - Lightweight REST API
- Docker Container - Containerized deployment
Prerequisites
Section titled “Prerequisites”| Requirement | Notes |
|---|---|
| Linux server | Ubuntu 22.04+ recommended |
| PostgreSQL 14+ | For backend database |
| Nginx | Optional, for reverse proxy |
| Docker | Optional, for containerized deployment |
Standalone Deployment
Section titled “Standalone Deployment”1. Prepare Server
Section titled “1. Prepare Server”# Update systemsudo apt update && sudo apt upgrade -y
# Install dependenciessudo apt install -y postgresql postgresql-contrib nginx
# Create app usersudo useradd -m -s /bin/bash ionflow2. Setup Database
Section titled “2. Setup Database”# Create PostgreSQL user and databasesudo -u postgres psql
CREATE USER ionflow WITH PASSWORD 'secure_password';CREATE DATABASE ion_flow OWNER ionflow;GRANT ALL PRIVILEGES ON DATABASE ion_flow TO ionflow;\q3. Deploy Binary
Section titled “3. Deploy Binary”# Copy binarysudo mkdir -p /opt/ionflowsudo cp bin/ion-flow /opt/ionflow/sudo chown -R ionflow:ionflow /opt/ionflow
# Create storage directoriessudo mkdir -p /opt/ionflow/storage/{dbs,store,repos}sudo chown -R ionflow:ionflow /opt/ionflow/storage
# Create environment filesudo nano /opt/ionflow/.env4. Environment Configuration
Section titled “4. Environment Configuration”PORT=8000DATABASE_URL=postgres://ionflow:secure_password@localhost:5432/ion_flow?sslmode=disableENVIRONMENT=productionFLOW_DB_PATH=/opt/ionflow/storage/dbsSTORE_DB_PATH=/opt/ionflow/storage/storeREPO_PATH=/opt/ionflow/storage/repos5. Systemd Service
Section titled “5. Systemd Service”[Unit]Description=ION Flow BackendAfter=network.target postgresql.service
[Service]Type=simpleUser=ionflowWorkingDirectory=/opt/ionflowEnvironmentFile=/opt/ionflow/.envExecStart=/opt/ionflow/ion-flowRestart=alwaysRestartSec=5
[Install]WantedBy=multi-user.target# Enable and start servicesudo systemctl daemon-reloadsudo systemctl enable ionflowsudo systemctl start ionflow
# Check statussudo systemctl status ionflow6. Nginx Reverse Proxy
Section titled “6. Nginx Reverse Proxy”upstream ionflow { server 127.0.0.1:8000;}
server { listen 80; server_name flow.example.com;
location / { proxy_pass http://ionflow; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $host; 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; }}# Enable sitesudo ln -s /etc/nginx/sites-available/ionflow /etc/nginx/sites-enabled/sudo nginx -tsudo systemctl reload nginxDocker Deployment
Section titled “Docker Deployment”Docker Compose
Section titled “Docker Compose”version: '3.8'
services: ionflow: image: ion-flow:latest build: . ports: - "8000:8000" environment: - PORT=8000 - DATABASE_URL=postgres://ionflow:password@db:5432/ion_flow?sslmode=disable - ENVIRONMENT=production volumes: - ./storage:/app/storage depends_on: - db restart: unless-stopped
db: image: postgres:14-alpine environment: - POSTGRES_USER=ionflow - POSTGRES_PASSWORD=password - POSTGRES_DB=ion_flow volumes: - postgres_data:/var/lib/postgresql/data restart: unless-stopped
volumes: postgres_data:# Deploydocker-compose up -d
# View logsdocker-compose logs -f ionflowServer Microservice Deployment
Section titled “Server Microservice Deployment”For lightweight deployments:
# Deploy server onlysudo mkdir -p /opt/flow-serversudo cp bin/flow-server /opt/flow-server/sudo mkdir -p /opt/flow-server/storage
# Systemd service# /etc/systemd/system/flow-server.service[Unit]Description=ION Flow ServerAfter=network.target
[Service]Type=simpleExecStart=/opt/flow-server/flow-server -port 8080 -path /opt/flow-server/storageRestart=alwaysRestartSec=5
[Install]WantedBy=multi-user.targetSSL/TLS Setup
Section titled “SSL/TLS Setup”Let’s Encrypt with Certbot
Section titled “Let’s Encrypt with Certbot”# Install certbotsudo apt install certbot python3-certbot-nginx
# Get certificatesudo certbot --nginx -d flow.example.com
# Auto-renewalsudo systemctl enable certbot.timerMonitoring
Section titled “Monitoring”Health Check
Section titled “Health Check”# Add health endpoint checkcurl http://localhost:8000/healthLogging
Section titled “Logging”# View logssudo journalctl -u ionflow -f
# Docker logsdocker logs -f ionflowProcess Monitoring
Section titled “Process Monitoring”# Using htophtop -p $(pgrep ion-flow)
# Memory usageps aux | grep ion-flowBackup Strategy
Section titled “Backup Strategy”Database Backup
Section titled “Database Backup”#!/bin/bashDATE=$(date +%Y%m%d_%H%M%S)BACKUP_DIR=/opt/ionflow/backups
# PostgreSQL backuppg_dump -U ionflow ion_flow > ${BACKUP_DIR}/db_${DATE}.sql
# SQLite backupscp -r /opt/ionflow/storage/dbs ${BACKUP_DIR}/dbs_${DATE}
# Cleanup old backups (keep 7 days)find ${BACKUP_DIR} -mtime +7 -deleteCron Job
Section titled “Cron Job”# Daily backup at 2am0 2 * * * /opt/ionflow/scripts/backup.shScaling
Section titled “Scaling”Horizontal Scaling
Section titled “Horizontal Scaling”For multiple instances:
- Use PostgreSQL for shared state
- Use Redis for session management
- Use load balancer for distribution
Load Balancer Configuration
Section titled “Load Balancer Configuration”upstream ionflow_cluster { server 10.0.0.1:8000; server 10.0.0.2:8000; server 10.0.0.3:8000;}
server { listen 80; server_name flow.example.com;
location / { proxy_pass http://ionflow_cluster; # ... other proxy settings }}Security Checklist
Section titled “Security Checklist”- Use HTTPS with valid SSL certificate
- Configure firewall (UFW/iptables)
- Use strong database passwords
- Restrict database access to localhost
- Regular security updates
- Log monitoring
- Backup verification
Troubleshooting
Section titled “Troubleshooting”Service Won’t Start
Section titled “Service Won’t Start”# Check logssudo journalctl -u ionflow -n 50
# Check permissionsls -la /opt/ionflow/
# Test manuallysudo -u ionflow /opt/ionflow/ion-flowDatabase Connection Issues
Section titled “Database Connection Issues”# Test PostgreSQL connectionpsql -h localhost -U ionflow -d ion_flow
# Check PostgreSQL statussudo systemctl status postgresqlPort Conflicts
Section titled “Port Conflicts”# Check port usagesudo lsof -i :8000sudo netstat -tlnp | grep 8000Related Documentation
Section titled “Related Documentation”- Development Guide - Development setup
- Building Guide - Build process
- Architecture - System overview