# panel-native Core Keeper runtime image.
FROM debian:12-slim

ENV DEBIAN_FRONTEND=noninteractive \
    TZ=Etc/UTC \
    LANG=en_US.UTF-8 \
    LC_ALL=en_US.UTF-8 \
    DISPLAY=:99

# Core Keeper is Unity headless-on-Linux; Unity still needs an X display
# even with -nographics (some subsystem probes fail otherwise), so Xvfb.
RUN dpkg --add-architecture i386 \
 && apt-get update \
 && apt-get install -y --no-install-recommends \
    ca-certificates \
    locales \
    tini \
    xvfb \
    xauth \
    lib32gcc-s1 \
    lib32stdc++6 \
    libc6:i386 \
    libxi6 \
    libxrandr2 \
 && sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen \
 && locale-gen \
 && apt-get clean \
 && rm -rf /var/lib/apt/lists/*

RUN groupadd -g 1000 panel \
 && useradd -u 1000 -g 1000 -m -s /bin/bash panel \
 && mkdir -p /game /game-saves \
 && chown -R panel:panel /game /game-saves

COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

EXPOSE 27015/udp

ENTRYPOINT ["/usr/bin/tini", "--", "/entrypoint.sh"]
