frappe_docker/zerops.yml
2025-10-22 17:12:17 +02:00

132 lines
No EOL
4.7 KiB
YAML

# Zerops configuration for Frappe/ERPNext deployment
# Creates managed database services and uses Docker Compose for application containers
zerops:
# MariaDB Database Service
- setup: db
base: mariadb@11
envSecrets:
MARIADB_ROOT_PASSWORD: ${dbPassword}
# Redis Cache Service (using Valkey - Redis compatible)
- setup: redis-cache
base: valkey@7.2
mode: NON_HA # Use HA in production
# Redis Queue Service (using Valkey - Redis compatible)
- setup: redis-queue
base: valkey@7.2
mode: NON_HA # Use HA in production
# Frappe/ERPNext Application Services (Docker Compose)
- setup: app
build:
# Deploy the custom docker-compose file to the runtime
deployFiles: ./docker-compose.zerops.yaml
addToRunPrepare: ./docker-compose.zerops.yaml
# Copy initialization scripts
deployFiles:
- ./docker-compose.zerops.yaml
- ./scripts/
run:
# Environment variables for Docker Compose services
envVariables:
# Image configuration
CUSTOM_IMAGE: frappe/erpnext
CUSTOM_TAG: v15.84.0
ERPNEXT_VERSION: v15.84.0
PULL_POLICY: always
RESTART_POLICY: unless-stopped
# Database connection (using Zerops service)
DB_HOST: db
DB_PORT: 3306
DB_PASSWORD: ${dbPassword}
# Redis connections (using Zerops Valkey services)
REDIS_CACHE: redis-cache:6379
REDIS_QUEUE: redis-queue:6379
# Site configuration
FRAPPE_SITE_NAME_HEADER: ${siteName}
ADMIN_PASSWORD: ${adminPassword}
# Frontend/Nginx configuration
UPSTREAM_REAL_IP_ADDRESS: 127.0.0.1
UPSTREAM_REAL_IP_HEADER: X-Forwarded-For
UPSTREAM_REAL_IP_RECURSIVE: "off"
PROXY_READ_TIMEOUT: 120
CLIENT_MAX_BODY_SIZE: 50m
# Site initialization and app installation
prepareCommands:
# Wait for database and Redis services
- |
echo "Waiting for database connection..."
while ! mariadb -hdb -P3306 -uroot -p${DB_PASSWORD} -e "SELECT 1;" 2>/dev/null; do
echo "Database not ready, waiting 5 seconds..."
sleep 5
done
echo "Database connection established"
- |
echo "Waiting for Redis cache (Valkey) connection..."
while ! redis-cli -h redis-cache -p 6379 ping 2>/dev/null; do
echo "Redis cache not ready, waiting 5 seconds..."
sleep 5
done
echo "Redis cache connection established"
- |
echo "Waiting for Redis queue (Valkey) connection..."
while ! redis-cli -h redis-queue -p 6379 ping 2>/dev/null; do
echo "Redis queue not ready, waiting 5 seconds..."
sleep 5
done
echo "Redis queue connection established"
# Pull Docker images
- docker compose -f docker-compose.zerops.yaml pull
# Install Frappe site and apps using dedicated script
- |
echo "🚀 Running site installation..."
chmod +x scripts/install-site.sh
./scripts/install-site.sh
echo "✅ Site installation completed"
# Start all application services
start: docker compose -f docker-compose.zerops.yaml up --force-recreate
# Expose the frontend port
ports:
- port: 8080
httpSupport: true
# Required secrets in Zerops dashboard:
# - dbPassword: Database password for MariaDB (e.g., "mySecureDbPassword123")
# - adminPassword: ERPNext admin user password (e.g., "myAdminPassword123")
# - siteName: Your site domain name (e.g., "mycompany.example.com")
#
# This configuration provides:
# ✅ Managed MariaDB service with automatic backups and scaling
# ✅ Dedicated Redis services for cache and queue (better performance)
# ✅ Docker Compose for Frappe containers only (simpler, faster)
# ✅ Automatic site initialization with custom apps
# ✅ Persistent storage managed by Zerops
# ✅ Service health monitoring and auto-restart
# ✅ Built-in service discovery (services connect by name)
#
# Architecture:
# - db: Managed MariaDB 11 service (default Zerops configuration)
# - redis-cache: Managed Valkey 7.2 service (default configuration, NON_HA mode)
# - redis-queue: Managed Valkey 7.2 service (default configuration, NON_HA mode)
# - app: Docker Compose with Frappe containers (backend, frontend, websocket, workers, scheduler)
#
# Benefits of managed services:
# - Automatic backups and point-in-time recovery
# - Built-in monitoring and alerting
# - Automatic security updates
# - High availability and failover
# - Performance optimization
# - No container overhead for databases