services:

  prometheus:
    image: prom/prometheus:v2.15.2
    restart: unless-stopped
    container_name: ${prometheusServName}
    volumes:
      - ./prometheus/:/etc/prometheus/
      - prometheus:/prometheus
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    command:
      - "--web.route-prefix=/"
      - "--web.external-url=https://${site}.${domain}/prometheus"
      - "--config.file=/etc/prometheus/prometheus.yml"
      - "--storage.tsdb.path=/prometheus"
      - "--web.console.libraries=/usr/share/prometheus/console_libraries"
      - "--web.console.templates=/usr/share/prometheus/consoles"
    networks:
      - traefikNet
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.prometheus-secure.entrypoints=websecure"
      - "traefik.http.middlewares.prometheus-stripprefix.stripprefix.prefixes=/prometheus"
      - "traefik.http.routers.prometheus-secure.rule=Host(`${site}.${domain}`) && PathPrefix(`/prometheus`)"
      # - "traefik.http.routers.prometheus-secure.tls=true"
      - "traefik.http.routers.prometheus-secure.middlewares=prometheus-stripprefix,test-adminiallowlist@file,traefik-auth"
      - "traefik.http.routers.prometheus-secure.service=prometheus"
      - "traefik.http.services.prometheus.loadbalancer.server.port=9090"
      - "traefik.docker.network=traefikNet"

  grafana:
    image: grafana/grafana:6.6.1
    restart: unless-stopped
    container_name: ${grafanaServName}
    volumes:
      - grafana:/var/lib/grafana
      - ./grafana/provisioning:/etc/grafana/provisioning
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    env_file:
      - grafana.env
    depends_on:
      - prometheus
    networks:
      - traefikNet
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.grafana-secure.entrypoints=websecure"
      - "traefik.http.middlewares.grafana-stripprefix.stripprefix.prefixes=/grafana"
      - "traefik.http.routers.grafana-secure.rule=Host(`${site}.${domain}`) && PathPrefix(`/grafana`)"
      # - "traefik.http.routers.grafana-secure.tls=true"
      - "traefik.http.routers.grafana-secure.service=grafana"
      - "traefik.http.routers.grafana-secure.middlewares=grafana-stripprefix,test-adminipallowlist@file,traefik-auth"
      - "traefik.http.services.grafana.loadbalancer.server.port=3000"
      - "traefik.docker.network=traefikNet"

networks:
  traefikNet:
    external: true
    name: traefikNet

volumes:
  prometheus:
  grafana: