version: "3"

services:
  mstream:
    container_name: mstream
    image: lscr.io/linuxserver/mstream:v5.11.4-ls101
    restart: unless-stopped
    ports:
      - ${APP_PORT}:3000
    volumes:
      - ${APP_DATA_DIR}/data/mstream-config:/data
      - ${ROOT_FOLDER_HOST}/media/data/music:/music
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=${TZ}
    networks:
      - tipi_main_network
    labels:
      # Main
      traefik.enable: true
      traefik.http.middlewares.mstream-web-redirect.redirectscheme.scheme: https
      traefik.http.services.mstream.loadbalancer.server.port: 3000
      # Web
      traefik.http.routers.mstream-insecure.rule: Host(`${APP_DOMAIN}`)
      traefik.http.routers.mstream-insecure.entrypoints: web
      traefik.http.routers.mstream-insecure.service: mstream
      traefik.http.routers.mstream-insecure.middlewares: mstream-web-redirect
      # Websecure
      traefik.http.routers.mstream.rule: Host(`${APP_DOMAIN}`)
      traefik.http.routers.mstream.entrypoints: websecure
      traefik.http.routers.mstream.service: mstream
      traefik.http.routers.mstream.tls.certresolver: myresolver
      # Local domain
      traefik.http.routers.mstream-local-insecure.rule: Host(`mstream.${LOCAL_DOMAIN}`)
      traefik.http.routers.mstream-local-insecure.entrypoints: web
      traefik.http.routers.mstream-local-insecure.service: mstream
      traefik.http.routers.mstream-local-insecure.middlewares: mstream-web-redirect
      # Local domain secure
      traefik.http.routers.mstream-local.rule: Host(`mstream.${LOCAL_DOMAIN}`)
      traefik.http.routers.mstream-local.entrypoints: websecure
      traefik.http.routers.mstream-local.service: mstream
      traefik.http.routers.mstream-local.tls: true