services:
  reverse-proxy:
    image: traefik:v3.6.2
    container_name: ${traefikServName}
    restart: ${restartPolicy}
    # Enables the web UI and tells Traefik to listen to docker
    ports:
      - ${MAIN_IP}:80:80
      - ${MAIN_IP}:443:443
      - ${MAIN_IP}:636:636
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ./conf:/etc/traefik/
      - letsencrypt:/letsencrypt
      - log:/log
    environment:
      - TRAEFIK_PROVIDERS_DOCKER=true
      - TRAEFIK_PROVIDERS_DOCKER_EXPOSEDBYDEFAULT=false
      - TRAEFIK_API=true
      - TRAEFIK_PROVIDERS_FILE_DIRECTORY=/etc/traefik
      - TRAEFIK_ENTRYPOINTS_web_ADDRESS=:80
      - TRAEFIK_ENTRYPOINTS_web_HTTP_REDIRECTIONS_ENTRYPOINT_TO=websecure
      - TRAEFIK_ENTRYPOINTS_websecure_ADDRESS=:443
      - TRAEFIK_ENTRYPOINTS_websecure_HTTP_TLS_CERTRESOLVER=letsencrypt
      - TRAEFIK_ENTRYPOINTS_websecure_HTTP_MIDDLEWARES=hsts@file,test-ipallowlist@file
      - TRAEFIK_ENTRYPOINTS_websecure_TRANSPORT_RESPONDINGTIMEOUTS_READTIMEOUT=600
      - TRAEFIK_ENTRYPOINTS_websecure_TRANSPORT_RESPONDINGTIMEOUTS_IDLETIMEOUT=600
      - TRAEFIK_ENTRYPOINTS_ldapsecure_ADDRESS=:636
      - TRAEFIK_CERTIFICATESRESOLVERS_letsencrypt_ACME_EMAIL=admin@${domain}
      - TRAEFIK_CERTIFICATESRESOLVERS_letsencrypt_ACME_CASERVER=${acme_server}
      - TRAEFIK_CERTIFICATESRESOLVERS_letsencrypt_ACME_STORAGE=/letsencrypt/acme.json
      - TRAEFIK_CERTIFICATESRESOLVERS_letsencrypt_ACME_HTTPCHALLENGE_ENTRYPOINT=web
      - TRAEFIK_API_DASHBOARD=true
      #pour la migration vers traefik3
      - TRAEFIK_CORE_DEFAULTRULESYNTAX=v3

      - TZ=Europe/Paris
      - TRAEFIK_ACCESSLOG=true
      - TRAEFIK_ACCESSLOG_FILEPATH=/log/traefik_acces.log
      - TRAEFIK_ACCESSLOG_FILTERS_STATUSCODES=404,403,401
      - TRAEFIK_LOG=true
      - TRAEFIK_LOG_LEVEL=INFO
      - TRAEFIK_LOG_FILEPATH=/log/traefik.log

    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.traefik_https.rule=Host(`${site}.${domain}`) && PathPrefix(`/api`, `/dashboard`)"
      - "traefik.http.routers.traefik_https.rule=Host(`${site}.${domain}`)"
      - "traefik.http.routers.traefik_https.entrypoints=websecure"
      - "traefik.http.routers.traefik_https.service=api@internal"
      - "traefik.http.routers.traefik_https.middlewares=test-adminipallowlist@file,traefik-auth"
      - "traefik.http.middlewares.traefik-auth.basicauth.usersfile=/etc/traefik/passfile"

    networks:
      - traefikNet
{{web
      - webNet
}}
{{jirafeau
      - jirafeauNet
}}
{{ethercalc
      - ethercalcNet
}}
{{etherpad
      - etherpadNet
}}
{{framadate
      - framadateNet
}}
{{ldap
      - ldapNet
}}
{{mobilizon
      - mobilizonNet
}}
{{cloud
      - cloudNet
}}
{{collabora
      - collaboraNet
}}
{{paheko
      - pahekoNet
}}
{{mattermost
      - mattermostNet
}}
{{roundcube
      - roundcubeNet
}}
{{gitea
      - giteaNet
}}
{{dokuwiki
      - dokuwikiNet
}}
{{postfix
      - postfixNet
}}
{{vaultwarden
      - vaultwardenNet
}}
{{imapsync
      - imapsyncNet
}}
{{castopod
      - castopodNet
}}
{{apikaz
      - apikazNet
}}
{{mastodon
      - mastodonNet
}}
{{peertube
      - peertubeNet
}}
{{spip
      - spipNet
}}

#### BEGIN ORGA USE_NET
#### END ORGA USE_NET

networks:
  traefikNet:
    external: true
    name: traefikNet
{{web
  webNet:
    external: true
    name: webNet
}}
{{jirafeau
  jirafeauNet:
    external: true
    name: jirafeauNet
}}
{{ethercalc
  ethercalcNet:
    external: true
    name: ethercalcNet
}}
{{etherpad
  etherpadNet:
    external: true
    name: etherpadNet
}}
{{framadate
  framadateNet:
    external: true
    name: framadateNet
}}
{{ldap
  ldapNet:
    external: true
    name: ldapNet
}}
{{mobilizon
  mobilizonNet:
    external: true
    name: mobilizonNet
}}
{{cloud
  cloudNet:
    external: true
    name: cloudNet
}}
{{collabora
  collaboraNet:
    external: true
    name: collaboraNet
}}
{{paheko
  pahekoNet:
    external: true
    name: pahekoNet
}}
{{mattermost
  mattermostNet:
    external: true
    name: mattermostNet
}}
{{roundcube
  roundcubeNet:
    external: true
    name: roundcubeNet
}}
{{gitea
  giteaNet:
    external: true
    name: giteaNet
}}
{{dokuwiki
  dokuwikiNet:
    external: true
    name: dokuwikiNet
}}
{{postfix
  postfixNet:
    external: true
    name: postfixNet
}}
{{vaultwarden
  vaultwardenNet:
    external: true
    name: vaultwardenNet
}}
{{imapsync
  imapsyncNet:
    external: true
    name: imapsyncNet
}}
{{castopod
  castopodNet:
    external: true
    name: castopodNet
}}
{{api
  apikazNet:
    external: true
    name: apikazNet
}}
{{mastodon
  mastodonNet:
    external: true
    name: mastodonNet
}}
{{peertube
  peertubeNet:
    external: true
    name: peertubeNet
}}
{{spip
  spipNet:
    external: true
    name: spipNet
}}


#### BEGIN ORGA DEF_NET
#### END ORGA DEF_NET

volumes:
  letsencrypt:
  log:
