# Project Reclaimer dedicated servers in Docker (Linux containers; the
# servers run under Wine). Full guide: docs/docker.md.
#
# This file is all a host needs: it runs the published image, so no copy
# of the repository and no build. Put it in a folder of its own, then:
#
#   1. Copy Halo 3's files from your own MCC installation into
#      server/game/ next to this file (halo3/halo3.dll, halo3/maps/shared.map,
#      the maps you host, and campaign.map with 040_voi.map for Forge's
#      campaign vehicles and AI). The image contains no game files.
#   2. Optional: a .env file next to this one with your settings
#      (see .env.example).
#   3. docker compose up -d
#      docker compose logs -f
#
# On first start the container writes a commented dedicated.toml into the
# server folder; edit it for names, maps, playlists and admins, then
# `docker compose restart`. Commands for running servers:
#   docker compose exec reclaimer dedicated status
#   docker compose exec reclaimer dedicated ban <player ID | IP | CIDR> --reason "..."
# Opt-in executable updates: RECLAIMER_DEDICATED_AUTO_UPDATE=true in .env.
# Update the container image: docker compose pull && docker compose up -d
#
# To build the image from a checkout of the repository instead, add
# compose.build.yaml (see there).

name: reclaimer

services:
  reclaimer:
    # The newest release; set IMAGE in .env to stay on one version.
    image: ${IMAGE:-ghcr.io/projectreclaimer/project-reclaimer-dedicated:latest}
    restart: unless-stopped
    # The supervisor stops each server cleanly on Ctrl+C (SIGINT).
    stop_signal: SIGINT
    stop_grace_period: 30s
    # Every RECLAIMER_DEDICATED_* setting in .env overrides dedicated.toml,
    # as do PUID, PGID and RECLAIMER_XVFB (see .env.example).
    env_file:
      - path: .env
        required: false
    volumes:
      - ${SERVER_DIR:-./server}:/server
      # Read-only: the servers never change the game files.
      - ${GAME_DIR:-./server/game}:/server/game:ro
      # The Forge library and other caches, kept across updates.
      - cache:/cache
    # The master's TCP port, and one UDP port per server in dedicated.toml
    # (49176 and 49177 for the two servers the first start creates). Change
    # them in .env; a published port must equal the port inside.
    ports:
      - "${RECLAIMER_DEDICATED_MASTER_PORT:-49175}:${RECLAIMER_DEDICATED_MASTER_PORT:-49175}/tcp"
      - "${GAME_PORTS:-49176-49177}:${GAME_PORTS:-49176-49177}/udp"
      # Remote console (docs/rcon.md): TCP at each game port number, for
      # tools on this machine only. Set RECLAIMER_DEDICATED_RCON_PASSWORD
      # and RECLAIMER_DEDICATED_RCON_ADDRESS=0.0.0.0 in .env too.
      # - "127.0.0.1:${GAME_PORTS:-49176-49177}:${GAME_PORTS:-49176-49177}/tcp"
    # On Linux, host networking replaces the port list: every port in
    # dedicated.toml is reachable without listing it, and UPnP can reach the
    # router. Uncomment this and remove "ports:" above.
    # network_mode: host
    security_opt:
      - no-new-privileges:true
    # Roughly: under 0.1 core and 100 MB per idle server, 0.25 core and
    # 1-2 GB per server during a game. Uncomment to cap the container.
    # cpus: "2"
    # mem_limit: 6g
    logging:
      driver: json-file
      options:
        max-size: 10m
        max-file: "3"

volumes:
  cache:
