name: pangolin
services:
  pangolin:
    image: fosrl/pangolin:latest
    container_name: pangolin
    restart: unless-stopped
    networks:
      - traefik
    volumes:
      - /srv/pangolin/config:/app/config
    labels:
    - "traefik.enable=true"
    - "traefik.http.routers.pangolin.entrypoints=websecure"
    - "traefik.http.routers.pangolin.rule=Host(`pangolin.knast.cc`)"
    - "traefik.http.routers.pangolin.tls.certresolver=letsencr"
    - "traefik.http.services.pangolin.loadbalancer.server.port=8000"

    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:3001/api/v1/"]
      interval: "3s"
      timeout: "3s"
      retries: 5

  gerbil:
    image: fosrl/gerbil:latest
    networks:
      - traefik
    container_name: gerbil
    restart: unless-stopped
    depends_on:
      pangolin:
        condition: service_healthy
    command:
      - --reachableAt=http://gerbil:3003
      - --generateAndSaveKeyTo=/var/config/key
      - --remoteConfig=http://pangolin:3001/api/v1/gerbil/get-config
      - --reportBandwidthTo=http://pangolin:3001/api/v1/gerbil/receive-bandwidth
    volumes:
      - /srv/pangolin/config:/var/config
    cap_add:
      - NET_ADMIN
      - SYS_MODULE
    # ports:
    #   - 51820:51820/udp
      # - 443:443 # Port for traefik because of the network_mode
      # - 80:80 # Port for traefik because of the network_mode

  # traefik:
  #   image: traefik:v3.3.3
  #   container_name: traefik
  #   restart: unless-stopped
  #   network_mode: service:gerbil # Ports appear on the gerbil service
  #   depends_on:
  #     pangolin:
  #       condition: service_healthy
  #   command:
  #     - --configFile=/etc/traefik/traefik.yml
  #   volumes:
  #     - "./config/traefik.yml:/traefik.yml:ro"
  #     # - ./config/traefik.yml:/etc/traefik:ro # Volume to store the Traefik configuration
  #     - /srv/traefik/letsencrypt:/letsencrypt # Volume to store the Let's Encrypt certificates
  #     - "/var/run/docker.sock:/var/run/docker.sock:ro"
  #     - /var/log/traefik/:/opt/traefik/logs
networks:
  traefik:
    external: true
