# Core Keeper — panel-native dedicated server module.
#
# Native Linux (Unity headless) from SteamCMD app 1963720. Unity server
# still touches X so we need Xvfb (same pattern as Empyrion). No RCON —
# admin is via in-game console when you hold the founders key.
#
# Reference: https://github.com/CubeCoders/AMPTemplates (CoreKeeperLinux.kvp)

id: core-keeper
name: "Core Keeper"
version: 0.1.0
authors:
  - panel contributors

supported_modes:
  - docker

runtime:
  docker:
    image: panel-core-keeper:latest
    # Host networking -- container shares the host net namespace, so
    # any port the game/mod binds is directly on the LAN. AMP-like
    # model. Multi-instance safety comes from env-driven per-instance
    # ports (panel allocator + env: mapping on each ports entry).
    network_mode: host
    browseable_root: /game-saves
    browseable_roots:
      - name: "Saves & Configs"
        path: /game-saves
        hint: "Worlds + server.json"
      - name: "Game Files"
        path: /game
        hint: "Server binaries"
    env:
      GAME_ID: ""                      # leave empty to generate a new world; set to rejoin
      WORLD_NAME: "panel"
      WORLD_MODE: "0"                  # 0 = normal, 1 = hardmode, 2 = creative
      MAX_PLAYERS: "10"
      # Pre-declared so the agent's env filter lets the panel-allocated
      # port flow through to the container (same trap as soulmask).
      # The entrypoint passes it as -port; default matches the port default.
      GAME_PORT: "27015"
    volumes:
      - { type: volume, name: "panel-$INSTANCE_ID-saves", container: "/game-saves" }
      - { type: volume, name: "panel-$INSTANCE_ID-game",  container: "/game" }
      - { target: "$DATA_PATH/logs", container: "/game-saves/logs" }

ports:
  - { name: game, proto: udp, default: 27015, required: true, env: GAME_PORT }

resources:
  min_ram_mb: 2048
  recommended_ram_mb: 4096
# Log-derived player events. Regexes converted from CubeCoders'
# AMPTemplates (core-keeper.kvp) — .NET (?<n>) syntax -> Go (?P<n>).
# Sourced-from-template; not yet exercised against a live client.
events:
  join:
    pattern: '\[userid:(?P<id>[^\]]+)\] player (?P<name>.+?) connected'
    kind: join
  leave:
    pattern: 'Disconnected from userid:(?P<id>\S+?) with reason'
    kind: leave


update_providers:
  - id: stable
    kind: steamcmd
    app_id: "1963720"
    install_path: /game

# --- Manifest-driven UI metadata (WI-07) --------------------------
# Consumed by the CONTROLLER/dashboard only (the controller loads its
# own ./modules copy at startup); the agent ignores these at runtime.
# ready_pattern is a JavaScript regex (slash-delimited when it needs
# flags) moved verbatim from the dashboard's READY_PATTERNS map.
# Verified on a live first boot 2026-07-14: the last line before the server
# accepts joins is "Started session with info: <ip>;<port>;<key1>;<key2>".
ready_pattern: '/Started session with info/i'
appearance:
  emoji: "⛏️"
  grad: "linear-gradient(135deg,#2e1a47,#6b3fa0)"
  art: "/game-art/core-keeper.jpg"
  steam: "1621690"
