services:
  pinchflat:
    image: keglin/pinchflat:v0.1.18
    container_name: pinchflat
    environment:
      - BASIC_AUTH_USERNAME=${PINCHFLAT_BASIC_AUTH_USERNAME}
      - BASIC_AUTH_PASSWORD=${PINCHFLAT_BASIC_AUTH_PASSWORD}
    restart: unless-stopped
    ports:
      - ${APP_PORT}:8945
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - ${APP_DATA_DIR}/data/config:/config
      - ${APP_DATA_DIR}/data/downloads:/downloads
    networks:
      - tipi_main_network
    labels:
      # Main
      traefik.enable: true
      traefik.http.middlewares.pinchflat-web-redirect.redirectscheme.scheme: https
      traefik.http.services.pinchflat.loadbalancer.server.port: 8945
      # Web
      traefik.http.routers.pinchflat-insecure.rule: Host(`${APP_DOMAIN}`)
      traefik.http.routers.pinchflat-insecure.entrypoints: web
      traefik.http.routers.pinchflat-insecure.service: pinchflat
      traefik.http.routers.pinchflat-insecure.middlewares: pinchflat-web-redirect
      # Websecure
      traefik.http.routers.pinchflat.rule: Host(`${APP_DOMAIN}`)
      traefik.http.routers.pinchflat.entrypoints: websecure
      traefik.http.routers.pinchflat.service: pinchflat
      traefik.http.routers.pinchflat.tls.certresolver: myresolver
      # Local domain
      traefik.http.routers.pinchflat-local-insecure.rule: Host(`pinchflat.${LOCAL_DOMAIN}`)
      traefik.http.routers.pinchflat-local-insecure.entrypoints: web
      traefik.http.routers.pinchflat-local-insecure.service: pinchflat
      traefik.http.routers.pinchflat-local-insecure.middlewares: pinchflat-web-redirect
      # Local domain secure
      traefik.http.routers.pinchflat-local.rule: Host(`pinchflat.${LOCAL_DOMAIN}`)
      traefik.http.routers.pinchflat-local.entrypoints: websecure
      traefik.http.routers.pinchflat-local.service: pinchflat
      traefik.http.routers.pinchflat-local.tls: true