services:
  scrutiny-influxdb:
    container_name: scrutiny-influxdb
    image: influxdb:2.1-alpine
    ports:
      - 8086:8086
    volumes:
      - ./scrutiny/config/influxdb2/db:/var/lib/influxdb2
      - ./scrutiny/config/influxdb2/config:/etc/influxdb2
    environment:
      - DOCKER_INFLUXDB_INIT_MODE=setup
      - DOCKER_INFLUXDB_INIT_USERNAME=Admin
      - DOCKER_INFLUXDB_INIT_PASSWORD=asdf1234
      - DOCKER_INFLUXDB_INIT_ORG=homelab
      - DOCKER_INFLUXDB_INIT_BUCKET=scrutiny
      - DOCKER_INFLUXDB_INIT_ADMIN_TOKEN=3249085v098scnm#386
    restart: unless-stopped
    networks:
      - monitoring

  scrutiny:
    container_name: scrutiny
    image: ghcr.io/analogj/scrutiny:master-web
    ports:
      - 8081:8080
    volumes:
      - ./scrutiny/config/scrutiny/config:/opt/scrutiny/config
    environment:
      - SCRUTINY_WEB_INFLUXDB_HOST=scrutiny-influxdb
      - SCRUTINY_WEB_INFLUXDB_PORT=8086
      - SCRUTINY_WEB_INFLUXDB_TOKEN=3249085v098scnm#386
      - SCRUTINY_WEB_INFLUXDB_ORG=homelab
      - SCRUTINY_WEB_INFLUXDB_BUCKET=scrutiny
      # Optional but highly recommended to notify you in case of a problem
      - SCRUTINY_NOTIFY_URLS=["http://192.168.1.202:9898/SMART"]
    depends_on:
      - scrutiny-influxdb
    restart: unless-stopped
    networks:
#      - notifications
      - monitoring

  glances:
    #image: nicolargo/glances:3.4.0.5-full
    image: nicolargo/glances:latest-full
    container_name: glances
    restart: unless-stopped
    pid: host
    ports:
      - 61208:61208
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      # Uncomment the below line if you want glances to display host OS detail instead of container's
      - /etc/os-release:/etc/os-release:ro
      - /mnt/restic:/restic
      - /:/host:ro
    environment:
      - "GLANCES_OPT=-w"

  uptime-kuma:
    image: louislam/uptime-kuma:1
    container_name: uptime-kuma
    volumes:
      - ./uptime-kuma/uptime-kuma-data:/app/data
    ports:
      - 3001:3001  # <Host Port>:<Container Port>
    restart: unless-stopped
    environment:
      - TZ="America/Sao_Paulo"

  ntfy:
    image: binwiederhier/ntfy
    container_name: ntfy
    command:
      - serve
    environment:
      - TZ=America/Sao_Paulo    # optional: Change to your desired timezone
    #user: UID:GID # optional: Set custom user/group or uid/gid
      - NTFY_ENABLE_LOGIN=true
      - NTFY_AUTH_FILE=/var/lib/ntfy/auth.db
      - NTFY_CACHE_FILE=/var/lib/ntfy/cache.db
      - NTFY_BASE_URL=https://ntfy.ccalifice.com
      - NTFY_AUTH_DEFAULT_ACCESS=deny-all
      - NTFY_BEHIND_PROXY=true
      - NTFY_ATTACHMENT_CACHE_DIR=/var/lib/ntfy/attachments
    volumes:
      - ./ntfy/var/cache/ntfy:/var/cache/ntfy
      - ./ntfy/var/lib/ntfy/:/var/lib/ntfy/
      - ./ntfy/etc/ntfy:/etc/ntfy
    ports:
      - 9898:80
    restart: unless-stopped
    networks:
      - caddy-net
      - default

  homepage:
    image: ghcr.io/gethomepage/homepage:latest
    container_name: homepage
    environment:
      PUID: 1000
      PGID: 1002
      HOMEPAGE_ALLOWED_HOSTS: 192.168.1.202:3000
    ports:
      - 3000:3000
    volumes:
      - ./homepage/config:/app/config # Make sure your local config directory exists
    restart: unless-stopped

  # glance:
  #   container_name: glance
  #   image: glanceapp/glance
  #   restart: unless-stopped
  #   volumes:
  #     - ./glance/config:/app/config
  #     - ./glance/assets:/app/assets
  #     - /etc/localtime:/etc/localtime:ro
  #     # Optionally, also mount docker socket if you want to use the docker containers widget
  #     - /var/run/docker.sock:/var/run/docker.sock:ro
  #   ports:
  #     - 3099:8080
  #   env_file: .env


##### Grafana 

#   loki:
#       container_name: loki
#       image: grafana/loki:latest
#       ports:
#         - "3100:3100"
#       command: -config.file=/etc/loki/local-config.yaml
#       networks:
#         - grafana

#   promtail:
#     container_name: promtail
#     image: grafana/promtail:latest
#     volumes:
#       - /grafana/var/log:/var/log
#     command: -config.file=/etc/promtail/config.yml
#     networks:
#       - grafana

#   alloy:
#     container_name: alloy
#     image: grafana/alloy:latest
#     profiles: ['alloy']
#     volumes:
#       - ./grafana/config/alloy:/etc/alloy

#   grafana:
#     environment:
#       - GF_PATHS_PROVISIONING=/etc/grafana/provisioning
# #      - GF_AUTH_ANONYMOUS_ENABLED=true
# #      - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
#       - GF_SECURITY_ADMIN_USER=ccalifice
#       - GF_SECURITY_ADMIN_PASSWORD=asdf1234
#       - GF_FEATURE_TOGGLES_ENABLE=alertingSimplifiedRouting,alertingQueryAndExpressionsStepMode
#     entrypoint:
#       - sh
#       - -euc
#       - |
#         mkdir -p /etc/grafana/provisioning/datasources
#         cat <<EOF > /etc/grafana/provisioning/datasources/ds.yaml
#         apiVersion: 1
#         datasources:
#         - name: Loki
#           type: loki
#           access: proxy
#           orgId: 1
#           url: http://loki:3100
#           basicAuth: false
#           isDefault: true
#           version: 1
#           editable: false
#         EOF
#         /run.sh
#     image: grafana/grafana:latest
#     ports:
#       - "3003:3000"
#     networks:
#       - grafana
#     volumes:
#       - ./grafana/data:/var/lib/grafana
#     user: "1000:1002"
#     container_name: grafana

#   prometheus:
#     image: prom/prometheus
#     volumes:
#       - "./grafana/prometheus.yml:/etc/prometheus/prometheus.yml"
#       - ./grafana/prometheus-data:/prometheus
#     networks:
#       - grafana
#     ports:
#       - 9090:9090
#     user: "1000:1002"
#     container_name: prometheus


#sudo docker plugin install grafana/loki-docker-driver:3.3.2-amd64 --alias loki --grant-all-permissions
# {
#     "debug" : true,
#     "log-driver": "loki",
#     "log-opts": {
#         "loki-url": "http://192.168.1.202:3100/loki/api/v1/push",
#         "loki-batch-size": "400"
#     },
# "insecure-registries":["192.168.1.202:6610"]
# }


networks:
  caddy-net:
    external: true
    name: caddy-net
  monitoring:
    name: monitoring-net
  
