# Project Reclaimer dedicated servers in Docker (Linux containers, the game
# running natively), every server in ONE container on published ports.
# Guide: docs/servers.md. Project Reclaimer 0.9's file, with the same
# service, folders and volume: a host of 0.9 updates with
#   docker compose pull && docker compose up -d
#
# compose.yaml, one container per server on the host's network, is the
# usual choice. Use this file where host networking is not available (Docker
# Desktop without it, or a host that must keep containers off its
# network): name it with -f, or COMPOSE_FILE=compose.single.yaml in .env.
#
# 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. Commands
# for running servers:
#   docker compose exec reclaimer dedicated status
#   docker compose exec reclaimer dedicated ban <player ID | IP | CIDR> --reason "..."
# Update to a new release: docker compose pull && docker compose up -d
#
# To build the image from a checkout of the repository instead, set
# `image: project-reclaimer-dedicated:local` below and add
# `build: {context: .., dockerfile: docker/Dockerfile}` (compose.build.yaml
# is for compose.yaml's services).

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 and PGID (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 port (TCP for the server browser, UDP for the servers'
    # registrations, players' introductions and STUN), 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"
      - "${RECLAIMER_DEDICATED_MASTER_PORT:-49175}:${RECLAIMER_DEDICATED_MASTER_PORT:-49175}/udp"
      - "${GAME_PORTS:-49176-49177}:${GAME_PORTS:-49176-49177}/udp"
      # Remote console (docs/servers.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, a core and
    # 0.6-0.9 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:
