---
version: "3.1"
services:
  wireguard:
    image: lscr.io/linuxserver/wireguard
    container_name: wireguard
    cap_add:
      - NET_ADMIN
      - SYS_MODULE
    environment:
      - PUID=$PUID
      - PGID=$PGID
      - TZ=Europe/London
      - SERVERURL=$SERVERURL
      - SERVERPORT=$SERVERPORT
      - PEERS=$PEERS
      - PEERDNS=none
      - ALLOWEDIPS=$ALLOWEDIPS
      - INTERNAL_SUBNET=$INTERNAL_SUBNET
    volumes:
      - ./wireguard/config:/config
      - /lib/modules:/lib/modules
    ports:
      - $SERVERPORT:$SERVERPORT/udp
      - 127.0.0.1:3000:3000
      - 127.0.0.1:5050:5000
    sysctls:
      - net.ipv4.conf.all.src_valid_mark=1
      - net.ipv4.ip_forward=1
    restart: unless-stopped

  grafana:
    image: grafana/grafana:8.3.3
    container_name: grafana
    volumes:
      - grafana_data:/var/lib/grafana
      - ./grafana/provisioning/dashboards:/etc/grafana/provisioning/dashboards
      - ./grafana/provisioning/datasources:/etc/grafana/provisioning/datasources
    environment:
      - GF_SECURITY_ADMIN_USER=$ADMIN
      - GF_SECURITY_ADMIN_PASSWORD=$PASSWORD
      - GF_USERS_ALLOW_SIGN_UP=false
    restart: unless-stopped
    labels:
      org.label-schema.group: "monitoring"
    network_mode: "service:wireguard"
    depends_on:
      - wireguard

  dynaconf:
    build: ./dynaconf
    restart: unless-stopped
    volumes:
      - database:/src/database
    network_mode: "service:wireguard"


volumes:
  database:
  grafana_data:
