services:
  grafana:
    image: grafana/grafana-oss:latest
    container_name: grafana_node${GF_NODE_ID}
    user: "1000:1000"
    restart: always
    environment:
      - GF_SERVER_ROOT_URL=https://${GF_HOST_NAME}.${TRAEFIK_DNS_SUFFIX}
      - GF_SECURITY_ADMIN_USER=${GF_USER_NAME}
      - GF_SECURITY_ADMIN_PASSWORD=${GF_USER_PASS}
      - GF_USERS_ALLOW_SIGN_UP=false
    volumes:
      - /shared/grafana/data:/var/lib/grafana
    ports:
      - "2999:3000"
    networks:
      - grafana_external
      - grafana_internal
    labels:
      - "traefik.enable=true"
      - "traefik.docker.network=grafana_external"
      - "traefik.http.routers.grafana.rule=Host(`${GF_HOST_NAME}.${TRAEFIK_DNS_SUFFIX}`)"
      - "traefik.http.routers.grafana.entrypoints=websecure"
      - "traefik.http.routers.grafana.tls=true"
      - "traefik.http.routers.grafana.tls.certresolver=dns_resolver"
      - "traefik.http.services.grafana.loadbalancer.server.port=3000"

networks:
  grafana_internal:
    driver: bridge
  grafana_external:
    external: true