# Don't Starve Together dedicated server (Steam app 343050).
# The game is NOT in the image: SteamCMD downloads/updates it on start and it stays in the /game volume.
FROM --platform=linux/amd64 ubuntu:22.04

ENV DEBIAN_FRONTEND=noninteractive
RUN dpkg --add-architecture i386 \
 && apt-get update \
 && apt-get install -y --no-install-recommends ca-certificates curl lib32gcc-s1 lib32stdc++6 libcurl4-gnutls-dev \
 && rm -rf /var/lib/apt/lists/*

RUN useradd -m -u 1000 steam \
 && mkdir -p /opt/steamcmd /game /data \
 && chown -R steam:steam /opt/steamcmd /game /data
USER steam
WORKDIR /opt/steamcmd
RUN curl -fsSL https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz | tar xz \
 && ./steamcmd.sh +quit || true

COPY --chown=steam:steam entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
VOLUME ["/game", "/data"]
EXPOSE 10999/udp 10998/udp
ENTRYPOINT ["/entrypoint.sh"]
