version: "3"

services:
  darkflamedb:
    image: mariadb:latest
    environment:
      - MARIADB_USER=${MARIADB_USER:-darkflame}
      - MARIADB_PASSWORD=${MARIADB_PASSWORD:-darkflame}
      - MARIADB_ROOT_PASSWORD=${MARIADB_ROOT_PASSWORD:-darkflame}
      - MARIADB_DATABASE=${MARIADB_DATABASE:-darkflame}
    networks:
      - darkflame

  darkflameserver:
    networks:
      - darkflame
    image: ghcr.io/darkflameuniverse/darkflameserver:latest
    volumes:
      - $HOST_CONFIG_DIR:/app/configs/
      - $HOST_CLIENT_LOCATION:$CLIENT_LOCATION:ro
      - $HOST_RESSERVER_LOCATION:/app/resServer/
      - $HOST_DUMP_FOLDER:$DUMP_FOLDER
      - $HOST_LOGS_DIR:/app/logs/
    environment:
      - DLU_CONFIG_DIR=/app/configs
      - MYSQL_HOST=darkflamedb
      - MYSQL_DATABASE=${MARIADB_DATABASE:-darkflame}
      - MYSQL_USERNAME=${MARIADB_USER:-darkflame}
      - MYSQL_PASSWORD=${MARIADB_PASSWORD:-darkflame}
      - EXTERNAL_IP=${EXTERNAL_IP:-localhost}
      - DUMP_FOLDER=$DUMP_FOLDER
      - CLIENT_LOCATION=$CLIENT_LOCATION
    depends_on:
      - darkflamedb
    ports:
      - "1001:1001/udp"
      - "2005:2005/udp"
      - "3000-3300:3000-3300/udp"

  darkflameweb:
    networks:
      - darkflame
    image: ghcr.io/darkflameuniverse/nexusdashboard:latest
    volumes:
      - $HOST_CLIENT_LOCATION:/app/luclient:ro
      - $HOST_CACHE_LOCATION:/app/cache
      - $HOST_CD_SQLITE_LOCATION:/app/cdclient:ro
    environment:
      - APP_SECRET_KEY=$APP_SECRET_KEY
      - APP_DATABASE_URI=mysql+pymysql://${MARIADB_USER:-darkflame}:${MARIADB_PASSWORD:-darkflame}@darkflamedb:3306/${MARIADB_DATABASE:-darkflame}
      - CLIENT_LOCATION=/app/luclient
      - CACHE_LOCATION=/app/cache
      - CD_SQLITE_LOCATION=/app/cdclient
    depends_on:
      - darkflamedb
    ports:
      - 8000:8000
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8000"]
      interval: 2m
      timeout: 3s
      retries: 3
      start_period: 40s

networks:
  darkflame:
