# Browser-first alternative. A container-dashboard operator supplies these two
# environment values, deploys the stack, and opens /setup at the chosen URL.
name: open-study-tracker
services:
  tracker:
    build:
      context: ../..
      dockerfile: open_tracker/deploy/Dockerfile
    command: [web, --host, 0.0.0.0]
    init: true
    restart: unless-stopped
    environment:
      TRACKER_SETUP_PUBLIC_URL: ${TRACKER_PUBLIC_URL:?Set the HTTPS public URL in your hosting dashboard}
      TRACKER_EXPECTED_PUBLIC_URL: ${TRACKER_PUBLIC_URL:?Set the HTTPS public URL in your hosting dashboard}
      TRACKER_SETUP_TOKEN: ${TRACKER_SETUP_TOKEN:?Set a private random setup key of at least 32 characters in your hosting dashboard}
    volumes:
      - tracker_data:/data
    read_only: true
    tmpfs:
      - /tmp:mode=1777,size=32m
    cap_drop: [ALL]
    security_opt: [no-new-privileges:true]
    stop_grace_period: 25s
    logging:
      options:
        max-size: 10m
        max-file: '3'
  proxy:
    image: caddy:2-alpine
    restart: unless-stopped
    environment:
      TRACKER_PUBLIC_URL: ${TRACKER_PUBLIC_URL:?Set the HTTPS public URL in your hosting dashboard}
    ports:
      - '80:80'
      - '443:443'
      - '443:443/udp'
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile:ro
      - caddy_data:/data
      - caddy_config:/config
    depends_on:
      tracker:
        condition: service_healthy
    logging:
      options:
        max-size: 10m
        max-file: '3'
volumes:
  tracker_data:
  caddy_data:
  caddy_config:
