services:
  gmod-prophunt:
    build:
      context: ..
      dockerfile: docker/Dockerfile
    container_name: gmod-prophunt
    restart: unless-stopped
    stdin_open: true
    tty: true

    environment:
      - SRCDS_TOKEN=${SRCDS_TOKEN:-}
      - SERVER_NAME=${SERVER_NAME:-PropHunt Server}
      - RCON_PASSWORD="REDACTED_PASSWORD"
      - MAX_PLAYERS=${MAX_PLAYERS:-24}
      - MAP=${MAP:-gm_construct}
      - PORT=${PORT:-27015}
      - GAMEMODE=${GAMEMODE:-prop_hunt}
      - WORKSHOP_COLLECTION=${WORKSHOP_COLLECTION:-}
      - TICKRATE=${TICKRATE:-66}
      - TZ=${TZ:-America/Los_Angeles}
      - AUTO_UPDATE=${AUTO_UPDATE:-true}

    ports:
      - "${PORT:-27015}:27015/tcp"
      - "${PORT:-27015}:27015/udp"
      - "27005:27005/udp"
      - "27020:27020/udp"

    volumes:
      # Persistent server files (includes addons, data, configs)
      - gmod-server:/home/gmod/serverfiles

    networks:
      - gmod-network

    # Required for Source engine servers
    ulimits:
      memlock:
        soft: -1
        hard: -1

    # Resource limits (optional, adjust as needed)
    deploy:
      resources:
        limits:
          cpus: '4'
          memory: 8G
        reservations:
          cpus: '1'
          memory: 2G

    # Logging configuration
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
        max-file: "3"

networks:
  gmod-network:
    driver: bridge

volumes:
  gmod-server:
