services:
  generator:
    build: .
    image: etplot-gallery:latest
    entrypoint: ["/app/deploy/entrypoint.sh"]
    environment:
      CONFIG_FILE: /config/config.yaml
      # How often to regenerate the gallery (seconds). Set to 0 to run once and exit.
      GENERATE_INTERVAL: "300"
    volumes:
      - ./config.yaml:/config/config.yaml:ro
      # Mount your plot source directories here, matching the paths in config.yaml.
      # Example:
      # - /path/to/plots:/plots:ro
      - gallery_output:/var/www/gallery
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "gallery", "--help"]
      interval: 60s
      timeout: 10s
      retries: 3
      start_period: 30s

  web:
    image: nginx:1.27-alpine
    ports:
      - "${HTTP_PORT:-8080}:80"
    volumes:
      - ./deploy/nginx.conf:/etc/nginx/conf.d/default.conf:ro
      - gallery_output:/var/www/gallery:ro
    depends_on:
      - generator
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "wget", "-qO-", "http://localhost/"]
      interval: 30s
      timeout: 5s
      retries: 3
      start_period: 10s

volumes:
  gallery_output:
