version: '3.8'

services:
  gotenberg:
    image: gotenberg/gotenberg:8
    container_name: odentas-gotenberg
    restart: unless-stopped
    ports:
      - "3001:3000"
    environment:
      # Configuration de sécurité
      - GOTENBERG_API_TIMEOUT=30s
      - GOTENBERG_API_ROOT_PATH=/
      
      # Limites de ressources pour éviter la surcharge
      - GOTENBERG_CHROMIUM_MAX_QUEUE_SIZE=10
      - GOTENBERG_CHROMIUM_AUTO_START=true
      
      # Options de conversion PDF
      - GOTENBERG_CHROMIUM_DISABLE_JAVASCRIPT=false
      - GOTENBERG_CHROMIUM_ALLOW_LIST=^file:///tmp/.*
      
    # Limites de ressources Docker
    deploy:
      resources:
        limits:
          cpus: '2'
          memory: 2G
        reservations:
          cpus: '0.5'
          memory: 512M
    
    # Health check pour vérifier que Gotenberg est opérationnel
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:3000/health"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s
    
    # Volumes pour logs et cache (optionnel)
    volumes:
      - gotenberg-cache:/tmp/gotenberg
    
    networks:
      - odentas-network

volumes:
  gotenberg-cache:
    driver: local

networks:
  odentas-network:
    driver: bridge
