version: '3'

services:
  nationsglory-modded:
    image: itzg/minecraft-server:java7
    container_name: mc-nationsglory
    restart: unless-stopped
    network_mode: "host"
    
    environment:
      # IMPORTANT: Ne pas utiliser TYPE, utiliser CUSTOM_SERVER directement
      # Cela force le conteneur à utiliser le JAR local au lieu de télécharger
      SERVER_PORT: "25565"
      RCON_PORT: "25575"
      SKIP_RCON: "true"
      SKIP_HEALTH_CHECK: "true"
      ACCEPT_EULA: "TRUE"
      EULA: "TRUE"
      ONLINE_MODE: "FALSE"
      DIFFICULTY: "1"
      GAMEMODE: "1"
      LEVEL_TYPE: "FLAT"
      MEMORY: "2G"
      INIT_MEMORY: "1G"
      JVM_OPTS: "-XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200"
      # CRITICAL: Désactiver le download automatique
      SKIP_SERVER_PROPERTIES: "false"
      # Pointer directement au JAR local
      CUSTOM_SERVER: "/data/mcpc.jar"
    
    entrypoint: []
    command:
      - sh
      - -c
      - |
        cd /data
        exec java -Xms1G -Xmx2G -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -jar mcpc.jar nogui
    
    volumes:
      - .:/data
    
    deploy:
      resources:
        limits:
          memory: 3G
        reservations:
          memory: 1G
    
    ulimits:
      nofile:
        soft: 65535
        hard: 65535
