services:
  caddy:
    image: lucaslorentz/caddy-docker-proxy:ci-alpine
    environment:
      - CADDY_INGRESS_NETWORKS=fluxer-shared
      - CADDY_DOCKER_CADDYFILE_PATH=/config/Caddyfile.base
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - caddy_data:/data
    configs:
      - source: caddyfile_config
        target: /config/Caddyfile.base
    networks:
      - fluxer-shared
    ports:
      - target: 80
        published: 8080
        protocol: tcp
        mode: host
      - target: 443
        published: 8443
        protocol: tcp
        mode: host
    deploy:
      mode: global
      placement:
        constraints:
          - node.role == manager
      restart_policy:
        condition: on-failure

configs:
  caddyfile_config:
    file: ./Caddyfile.global

networks:
  fluxer-shared:
    external: true

volumes:
  caddy_data:
