Deployment with Docker Compose
This guide will help you deploy Loonflow in a production environment using Docker Compose.
Prerequisites
Before starting, ensure you have the following requirements:
Linux server (refer to Server Hardware Requirements)
Docker 20.10+ installed
Docker Compose 2.0+ installed
Installing Docker and Docker Compose
If Docker and Docker Compose are not yet installed on your server, follow these steps:
Install Docker:
# Ubuntu/Debian curl -fsSL https://get.docker.com -o get-docker.sh sudo sh get-docker.sh # CentOS/RHEL sudo yum install -y docker sudo systemctl start docker sudo systemctl enable docker
Install Docker Compose:
# Download the latest version of Docker Compose sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose sudo chmod +x /usr/local/bin/docker-compose
Verify installation:
docker --version docker-compose --version
Downloading Docker Compose Configuration Files
Create a deployment directory:
mkdir -p /opt/loonflow cd /opt/loonflow
Download the necessary configuration files:
wget https://raw.githubusercontent.com/blackholll/loonflow/refs/heads/master/docker_compose_deploy/docker-compose.yml wget https://raw.githubusercontent.com/blackholll/loonflow/refs/heads/master/docker_compose_deploy/.env
Alternatively, if you have already cloned the repository, you can copy the files directly:
Configuring Environment Variables
Edit the .env file to configure the following necessary environment variables:
# Edit the .env file
vi .env
Important Configuration Items:
Database Configuration:
POSTGRES_USER: PostgreSQL database username (default: loonflow)POSTGRES_PASSWORD: PostgreSQL database password (must be changed)POSTGRES_DB: Database name (default: loonflow)POSTGRES_PORT: PostgreSQL port (default: 5432)
Redis Configuration:
REDIS_PASSWORD: Redis password (must be changed)REDIS_PORT: Redis port (default: 6379)
Administrator Account Configuration:
ADMIN_EMAIL: Administrator email (for login)ADMIN_NAME: Administrator usernameADMIN_PASSWORD: Administrator password (must be changed)
Tenant Configuration:
TENANT_NAME: Tenant nameTENANT_DOMAIN: Tenant domain
Data Volume Configuration:
PG_DATA_VOLUME: PostgreSQL data volume name (for data persistence)
Security Note: Please ensure to change all password-related configuration items and use strong passwords to ensure system security.
Starting Services
Ensure you are in the directory containing the
docker-compose.ymlfile:cd /opt/loonflow
Start all services:
docker-compose up -d
This command will start the following services in the background:
loonflow-redis: Redis service (for generating ticket serial numbers and Celery async tasks)
loonflow-pg: PostgreSQL database service
loonflow-backend: Loonflow backend service (Django + Gunicorn)
loonflow-ui: Loonflow frontend service (Nginx)
loonflow-task: Celery task processing service
Check service status:
docker-compose psView service logs (optional):
# View logs for all services docker-compose logs -f # View logs for a specific service docker-compose logs -f loonflow-backend
Accessing the Application
After the services are started, you can access Loonflow through your browser:
Access URL:
http://your_server_ip:80Login Credentials:
Email: The
ADMIN_EMAILyou configured in the.envfilePassword: The
ADMIN_PASSWORDyou configured in the.envfile
Common Management Commands
Stop services:
docker-compose stopStart services:
docker-compose startRestart services:
docker-compose restartStop and remove containers:
docker-compose downStop and remove containers and volumes (Warning: This will delete database data):
docker-compose down -v
Update services:
# Pull the latest images docker-compose pull # Recreate and start containers docker-compose up -d
Troubleshooting
If you encounter issues, try the following steps:
Check service status:
docker-compose psView service logs:
docker-compose logs [service_name]
Check port usage:
# Check if port 80 is in use netstat -tulpn | grep :80
Check firewall settings:
Ensure the firewall allows the following ports:
80: HTTP access
8000: Backend API (if direct access is needed)
5432: PostgreSQL (if external access is needed)
6379: Redis (if external access is needed)
Restart service:
docker-compose restart [service_name]
Important Notes
On first startup, the backend service will automatically perform database migrations and create a superuser, which may take a few minutes
Ensure the server has sufficient resources (CPU, memory, disk space)
Regularly backup the PostgreSQL data volume (
pg_data)Production environments should configure HTTPS and a reverse proxy