version: "3"

services:
  grafana:
    container_name: grafana
    image: grafana/grafana-oss:10.4.2
    ports:
      - ${APP_PORT}:3000
    volumes:
      - ${APP_DATA_DIR}/data/grafana:/var/lib/grafana
    networks:
      - tipi_main_network
    labels:
      # Main
      traefik.enable: true
      traefik.http.middlewares.grafana-web-redirect.redirectscheme.scheme: https
      traefik.http.services.grafana.loadbalancer.server.port: 3000
      # Web
      traefik.http.routers.grafana-insecure.rule: Host(`${APP_DOMAIN}`)
      traefik.http.routers.grafana-insecure.entrypoints: web
      traefik.http.routers.grafana-insecure.service: grafana
      traefik.http.routers.grafana-insecure.middlewares: grafana-web-redirect
      # Websecure
      traefik.http.routers.grafana.rule: Host(`${APP_DOMAIN}`)
      traefik.http.routers.grafana.entrypoints: websecure
      traefik.http.routers.grafana.service: grafana
      traefik.http.routers.grafana.tls.certresolver: myresolver
      # Local domain
      traefik.http.routers.grafana-local-insecure.rule: Host(`grafana.${LOCAL_DOMAIN}`)
      traefik.http.routers.grafana-local-insecure.entrypoints: web
      traefik.http.routers.grafana-local-insecure.service: grafana
      traefik.http.routers.grafana-local-insecure.middlewares: grafana-web-redirect
      # Local domain secure
      traefik.http.routers.grafana-local.rule: Host(`grafana.${LOCAL_DOMAIN}`)
      traefik.http.routers.grafana-local.entrypoints: websecure
      traefik.http.routers.grafana-local.service: grafana
      traefik.http.routers.grafana-local.tls: true
