version: '3.8'

services:
  chess-tutor:
    build:
      context: .
      dockerfile: Dockerfile
    image: chess-tutor:local
    container_name: chess-tutor
    restart: unless-stopped

    ports:
      - "3050:3050"

    env_file:
      - .env

    environment:
      - NODE_ENV=production
      # Data Privacy & Imprint Configuration
      - IMPRINT_URL=${IMPRINT_URL:-}
      - DATA_PRIVACY_RESPONSIBLE_PERSON=${DATA_PRIVACY_RESPONSIBLE_PERSON:-}

    volumes:
      # Persist Wikipedia cache to avoid re-fetching on container restart
      - wikipedia-cache:/app/public/wikipedia

    healthcheck:
      test: ["CMD", "node", "-e", "require('http').get('http://localhost:3050', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s

    networks:
      - chess-tutor-network

networks:
  chess-tutor-network:
    driver: bridge

volumes:
  wikipedia-cache:
    driver: local
