services:  
  portfolio:
    image: portfolio
    container_name: portfolio
    restart: unless-stopped
    environment:
      - TZ=Europe/Paris
    networks:
      - public
    labels:
      - 'traefik.enable=true'
      - 'com.centurylinklabs.watchtower.enable=false'
      - 'traefik.http.services.portfolio.loadbalancer.server.port=80'
      # Main router (non-www)
      - 'traefik.http.routers.portfolio.rule=Host(`${PORTFOLIO_URL}`)'
      - 'traefik.http.routers.portfolio.entrypoints=websecure'
      - 'traefik.http.routers.portfolio.tls.certresolver=public'
      - 'traefik.http.routers.portfolio.tls.domains[0].main=killiandalcin.fr'
      - 'traefik.http.routers.portfolio.tls.domains[0].sans=*.killiandalcin.fr'
      # WWW redirect router
      - 'traefik.http.routers.portfolio-www-redirect.rule=Host(`${PORTFOLIO_URL_WWW}`)'
      - 'traefik.http.routers.portfolio-www-redirect.entrypoints=websecure'
      - 'traefik.http.routers.portfolio-www-redirect.tls.certresolver=public'
      - 'traefik.http.routers.portfolio-www-redirect.middlewares=www-to-non-www'
      - 'traefik.http.routers.portfolio-www-redirect.service=noop@internal'
      # Redirect middleware
      - 'traefik.http.middlewares.www-to-non-www.redirectregex.regex=^https://www\.(.+)'
      - 'traefik.http.middlewares.www-to-non-www.redirectregex.replacement=https://$${1}'
      - 'traefik.http.middlewares.www-to-non-www.redirectregex.permanent=true'

networks:
  public:
    driver: bridge
    external: true
