version: '3.8'
services:
  fail2ban:
    image: lscr.io/linuxserver/fail2ban:latest
    container_name: fail2ban
    cap_add:
      - NET_ADMIN
      - NET_RAW
    network_mode: host
    environment:
      - PUID=1011
      - PGID=1001
      - TZ=Etc/UTC
      - VERBOSITY=-vv #optional
      
    volumes:
      - /server/server_fail2ban/config:/config
      - /server/server_fail2ban/fail2ban-run:/var/run/fail2ban
      - /var/log:/var/log
      - /server/server_nextcloud/config/nextcloud.log:/remotelogs/nextcloud/nextcloud.log:ro #optional
      - /server/server_nginx/data/logs:/remotelogs/nginx:ro #optional
      - /server/server_gitea/log/gitea.log:/remotelogs/gitea/gitea.log:ro #optional
      

      #- /path/to/homeassistant/log:/remotelogs/homeassistant:ro #optional
      #- /path/to/unificontroller/log:/remotelogs/unificontroller:ro #optional
      #- /path/to/vaultwarden/log:/remotelogs/vaultwarden:ro #optional
    restart: unless-stopped

  backend:
      image: git.lpl-mind.de/lukas.pupkalipinski/bangui/backend:latest
      container_name: bangui-backend
      restart: unless-stopped
      depends_on:
        fail2ban:
          condition: service_started
      environment:
        - PUID=1011
        - PGID=1001
        - BANGUI_DATABASE_PATH=/data/bangui.db
        - BANGUI_FAIL2BAN_SOCKET=/var/run/fail2ban/fail2ban.sock
        - BANGUI_FAIL2BAN_CONFIG_DIR=/config/fail2ban
        - BANGUI_LOG_LEVEL=info
        - BANGUI_SESSION_SECRET=${BANGUI_SESSION_SECRET:?Set BANGUI_SESSION_SECRET}
        - BANGUI_TIMEZONE=${BANGUI_TIMEZONE:-UTC}
      volumes:
        - /server/server_fail2ban/bangui-data:/data
        - /server/server_fail2ban/fail2ban-run:/var/run/fail2ban:ro
        - /server/server_fail2ban/config:/config:rw
      expose:
        - "8000"
      networks:
        - bangui-net
  
    # ── Frontend (nginx serving built SPA + API proxy) ──────────
  frontend:
    image: git.lpl-mind.de/lukas.pupkalipinski/bangui/frontend:latest
    container_name: bangui-frontend
    restart: unless-stopped
    environment:
      - PUID=1011
      - PGID=1001
    ports:
      - "${BANGUI_PORT:-8080}:80"
    depends_on:
      backend:
        condition: service_started
    networks:
      - bangui-net
  
networks:
  bangui-net:
    name: bangui-net