# Production-optimized Docker Compose for Dokploy # Bu dosya production deployment için optimize edilmiş ayarları içerir x-customizable-image: &customizable_image image: ghcr.io/ubden/frappe_docker/erpnext-complete:latest pull_policy: always restart: unless-stopped x-depends-on-configurator: &depends_on_configurator depends_on: configurator: condition: service_completed_successfully x-backend-defaults: &backend_defaults <<: [*depends_on_configurator, *customizable_image] volumes: - sites:/home/frappe/frappe-bench/sites - logs:/home/frappe/frappe-bench/logs networks: - erpnext-network services: mariadb: image: mariadb:10.6 restart: unless-stopped command: - --character-set-server=utf8mb4 - --collation-server=utf8mb4_unicode_ci - --skip-character-set-client-handshake - --skip-innodb-read-only-compressed - --max-connections=1000 - --innodb-buffer-pool-size=4G - --innodb-log-file-size=1G - --innodb-flush-log-at-trx-commit=2 - --innodb-flush-method=O_DIRECT - --query-cache-size=0 - --query-cache-type=0 - --innodb-read-io-threads=8 - --innodb-write-io-threads=8 environment: MYSQL_ROOT_PASSWORD: ${DB_PASSWORD} MYSQL_DATABASE: frappe volumes: - mariadb-data:/var/lib/mysql networks: - erpnext-network healthcheck: test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p${DB_PASSWORD}"] interval: 10s timeout: 5s retries: 5 start_period: 60s deploy: resources: limits: memory: 6G reservations: memory: 4G redis-cache: image: redis:7-alpine restart: unless-stopped command: - redis-server - --appendonly yes - --maxmemory 2gb - --maxmemory-policy allkeys-lru volumes: - redis-cache-data:/data networks: - erpnext-network healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 10s timeout: 5s retries: 5 deploy: resources: limits: memory: 2G redis-queue: image: redis:7-alpine restart: unless-stopped command: - redis-server - --appendonly yes - --maxmemory 1gb - --maxmemory-policy noeviction volumes: - redis-queue-data:/data networks: - erpnext-network healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 10s timeout: 5s retries: 5 deploy: resources: limits: memory: 1G configurator: <<: *backend_defaults platform: linux/amd64 entrypoint: - bash - -c command: - > ls -1 apps > sites/apps.txt; bench set-config -g db_host mariadb; bench set-config -gp db_port 3306; bench set-config -g redis_cache "redis://redis-cache:6379"; bench set-config -g redis_queue "redis://redis-queue:6379"; bench set-config -g redis_socketio "redis://redis-queue:6379"; bench set-config -gp socketio_port 9000; environment: DB_HOST: mariadb DB_PORT: 3306 REDIS_CACHE: redis-cache:6379 REDIS_QUEUE: redis-queue:6379 SOCKETIO_PORT: 9000 depends_on: mariadb: condition: service_healthy redis-cache: condition: service_healthy redis-queue: condition: service_healthy restart: "no" create-site: <<: *backend_defaults platform: linux/amd64 command: - bash - -c - | wait-for-it -t 120 mariadb:3306; wait-for-it -t 120 redis-cache:6379; wait-for-it -t 120 redis-queue:6379; if [ ! -f /home/frappe/frappe-bench/sites/${SITE_NAME}/site_config.json ]; then bench new-site ${SITE_NAME} --admin-password=${ADMIN_PASSWORD} --db-root-password=${DB_PASSWORD} --install-app erpnext --install-app crm --install-app lms --install-app builder --install-app print_designer --install-app payments --install-app wiki --install-app twilio_integration --install-app erpnext_shipping --no-mariadb-socket; bench --site ${SITE_NAME} set-config developer_mode 0; bench --site ${SITE_NAME} set-config maintenance_mode 0; bench --site ${SITE_NAME} clear-cache; else echo "Site already exists, skipping site creation"; fi environment: SITE_NAME: ${SITE_NAME} ADMIN_PASSWORD: ${ADMIN_PASSWORD} DB_PASSWORD: ${DB_PASSWORD} depends_on: configurator: condition: service_completed_successfully mariadb: condition: service_healthy restart: "no" backend: <<: *backend_defaults platform: linux/amd64 command: - /home/frappe/frappe-bench/env/bin/gunicorn - --chdir=/home/frappe/frappe-bench/sites - --bind=0.0.0.0:8000 - --threads=8 - --workers=4 - --worker-class=gthread - --worker-tmp-dir=/dev/shm - --timeout=300 - --graceful-timeout=30 - --preload - --max-requests=5000 - --max-requests-jitter=500 - frappe.app:application depends_on: create-site: condition: service_completed_successfully healthcheck: test: ["CMD-SHELL", "curl -f http://localhost:8000/api/method/ping || exit 1"] interval: 30s timeout: 10s retries: 3 start_period: 120s deploy: resources: limits: memory: 2G reservations: memory: 1G frontend: <<: *customizable_image platform: linux/amd64 command: - nginx-entrypoint.sh environment: BACKEND: backend:8000 SOCKETIO: websocket:9000 FRAPPE_SITE_NAME_HEADER: ${FRAPPE_SITE_NAME_HEADER:-$$host} UPSTREAM_REAL_IP_ADDRESS: ${UPSTREAM_REAL_IP_ADDRESS:-127.0.0.1} UPSTREAM_REAL_IP_HEADER: ${UPSTREAM_REAL_IP_HEADER:-X-Forwarded-For} UPSTREAM_REAL_IP_RECURSIVE: ${UPSTREAM_REAL_IP_RECURSIVE:-off} PROXY_READ_TIMEOUT: ${PROXY_READ_TIMEOUT:-300} CLIENT_MAX_BODY_SIZE: ${CLIENT_MAX_BODY_SIZE:-100m} volumes: - sites:/home/frappe/frappe-bench/sites depends_on: - backend - websocket networks: - erpnext-network ports: - "${HTTP_PORT:-80}:8080" healthcheck: test: ["CMD-SHELL", "curl -f http://localhost:8080/api/method/ping || exit 1"] interval: 30s timeout: 10s retries: 3 start_period: 60s deploy: resources: limits: memory: 512M websocket: <<: [*depends_on_configurator, *customizable_image] platform: linux/amd64 command: - node - /home/frappe/frappe-bench/apps/frappe/socketio.js volumes: - sites:/home/frappe/frappe-bench/sites depends_on: create-site: condition: service_completed_successfully networks: - erpnext-network deploy: resources: limits: memory: 512M queue-short: <<: *backend_defaults platform: linux/amd64 command: bench worker --queue short,default depends_on: create-site: condition: service_completed_successfully deploy: replicas: 2 resources: limits: memory: 1G queue-long: <<: *backend_defaults platform: linux/amd64 command: bench worker --queue long,default,short depends_on: create-site: condition: service_completed_successfully deploy: replicas: 2 resources: limits: memory: 1G scheduler: <<: *backend_defaults platform: linux/amd64 command: bench schedule depends_on: create-site: condition: service_completed_successfully deploy: resources: limits: memory: 512M volumes: mariadb-data: driver: local redis-cache-data: driver: local redis-queue-data: driver: local sites: driver: local logs: driver: local networks: erpnext-network: driver: bridge