Skip to content

Deployment Guide

Deploying ION Flow - Complete guide for deploying to production.


ION Flow can be deployed as:

  1. Standalone Backend - Full application with WebSocket support
  2. Server Microservice - Lightweight REST API
  3. Docker Container - Containerized deployment

RequirementNotes
Linux serverUbuntu 22.04+ recommended
PostgreSQL 14+For backend database
NginxOptional, for reverse proxy
DockerOptional, for containerized deployment

Terminal window
# Update system
sudo apt update && sudo apt upgrade -y
# Install dependencies
sudo apt install -y postgresql postgresql-contrib nginx
# Create app user
sudo useradd -m -s /bin/bash ionflow
Terminal window
# Create PostgreSQL user and database
sudo -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;
\q
Terminal window
# Copy binary
sudo mkdir -p /opt/ionflow
sudo cp bin/ion-flow /opt/ionflow/
sudo chown -R ionflow:ionflow /opt/ionflow
# Create storage directories
sudo mkdir -p /opt/ionflow/storage/{dbs,store,repos}
sudo chown -R ionflow:ionflow /opt/ionflow/storage
# Create environment file
sudo nano /opt/ionflow/.env
/opt/ionflow/.env
PORT=8000
DATABASE_URL=postgres://ionflow:secure_password@localhost:5432/ion_flow?sslmode=disable
ENVIRONMENT=production
FLOW_DB_PATH=/opt/ionflow/storage/dbs
STORE_DB_PATH=/opt/ionflow/storage/store
REPO_PATH=/opt/ionflow/storage/repos
/etc/systemd/system/ionflow.service
[Unit]
Description=ION Flow Backend
After=network.target postgresql.service
[Service]
Type=simple
User=ionflow
WorkingDirectory=/opt/ionflow
EnvironmentFile=/opt/ionflow/.env
ExecStart=/opt/ionflow/ion-flow
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
Terminal window
# Enable and start service
sudo systemctl daemon-reload
sudo systemctl enable ionflow
sudo systemctl start ionflow
# Check status
sudo systemctl status ionflow
/etc/nginx/sites-available/ionflow
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;
}
}
Terminal window
# Enable site
sudo ln -s /etc/nginx/sites-available/ionflow /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx

docker-compose.yml
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:
Terminal window
# Deploy
docker-compose up -d
# View logs
docker-compose logs -f ionflow

For lightweight deployments:

Terminal window
# Deploy server only
sudo mkdir -p /opt/flow-server
sudo 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 Server
After=network.target
[Service]
Type=simple
ExecStart=/opt/flow-server/flow-server -port 8080 -path /opt/flow-server/storage
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target

Terminal window
# Install certbot
sudo apt install certbot python3-certbot-nginx
# Get certificate
sudo certbot --nginx -d flow.example.com
# Auto-renewal
sudo systemctl enable certbot.timer

Terminal window
# Add health endpoint check
curl http://localhost:8000/health
Terminal window
# View logs
sudo journalctl -u ionflow -f
# Docker logs
docker logs -f ionflow
Terminal window
# Using htop
htop -p $(pgrep ion-flow)
# Memory usage
ps aux | grep ion-flow

/opt/ionflow/scripts/backup.sh
#!/bin/bash
DATE=$(date +%Y%m%d_%H%M%S)
BACKUP_DIR=/opt/ionflow/backups
# PostgreSQL backup
pg_dump -U ionflow ion_flow > ${BACKUP_DIR}/db_${DATE}.sql
# SQLite backups
cp -r /opt/ionflow/storage/dbs ${BACKUP_DIR}/dbs_${DATE}
# Cleanup old backups (keep 7 days)
find ${BACKUP_DIR} -mtime +7 -delete
Terminal window
# Daily backup at 2am
0 2 * * * /opt/ionflow/scripts/backup.sh

For multiple instances:

  • Use PostgreSQL for shared state
  • Use Redis for session management
  • Use load balancer for distribution
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
}
}

  • 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

Terminal window
# Check logs
sudo journalctl -u ionflow -n 50
# Check permissions
ls -la /opt/ionflow/
# Test manually
sudo -u ionflow /opt/ionflow/ion-flow
Terminal window
# Test PostgreSQL connection
psql -h localhost -U ionflow -d ion_flow
# Check PostgreSQL status
sudo systemctl status postgresql
Terminal window
# Check port usage
sudo lsof -i :8000
sudo netstat -tlnp | grep 8000