# External render-worker configuration.
#
# Use this compose file on remote machines (GPU nodes, NAS, cloud VMs) that
# only need Redis + MinIO access — no database, no backend, no frontend.
#
# Usage on remote machine:
#   export REDIS_URL=redis://main-server:6379/0
#   export MINIO_URL=http://main-server:9000
#   export MINIO_USER=minioadmin
#   export MINIO_PASSWORD=minioadmin
#   docker compose -f docker-compose.worker.yml up -d
#
# Requirements on remote machine:
#   - Blender >= 5.0.1 installed at /opt/blender (or set BLENDER_BIN)
#   - Docker + GPU drivers (NVIDIA recommended)

services:
  render-worker:
    image: schaefflerautomat-render-worker:latest
    # Or build locally: build: { context: ./render-worker, dockerfile: Dockerfile }
    environment:
      - REDIS_URL=${REDIS_URL:?Set REDIS_URL to the main server Redis URL}
      - POSTGRES_HOST=${POSTGRES_HOST:?Set POSTGRES_HOST to the main server DB host}
      - POSTGRES_DB=${POSTGRES_DB:-schaeffler}
      - POSTGRES_USER=${POSTGRES_USER:-schaeffler}
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD}
      - POSTGRES_PORT=${POSTGRES_PORT:-5432}
      - MINIO_URL=${MINIO_URL:?Set MINIO_URL to the main server MinIO URL}
      - MINIO_USER=${MINIO_USER:-minioadmin}
      - MINIO_PASSWORD=${MINIO_PASSWORD:-minioadmin}
      - MINIO_BUCKET=${MINIO_BUCKET:-uploads}
      - UPLOAD_DIR=/tmp/render-cache
      - BLENDER_BIN=${BLENDER_BIN:-/opt/blender/blender}
      - RENDER_SCRIPTS_DIR=/render-scripts
      - JWT_SECRET_KEY=${JWT_SECRET_KEY:?Set JWT_SECRET_KEY}
    volumes:
      - /opt/blender:/opt/blender:ro
      - render-cache:/tmp/render-cache
    deploy:
      replicas: ${RENDER_WORKER_REPLICAS:-1}
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: 1
              capabilities: [gpu, compute, utility, graphics]

volumes:
  render-cache:
