fixed the Dockerfile, aperently the server has to be installed at runtime and there was also an issue with permissions which can be fixed by manually creating the direcotry data with the correct permissions. If you dont do this it will install in the default directory.

There is currently an issue with the server crashing everytime i try to join, no idea why it happens...
This commit is contained in:
bacalhau 2025-11-04 12:00:59 +00:00
parent 2084cfdf92
commit a7001cbac7
2 changed files with 17 additions and 33 deletions

View file

@ -1,17 +1,18 @@
############################################################
# Dockerfile that contains SteamCMD
# Counter-Strike dedicated server
############################################################
FROM debian:bookworm-slim as build_stage
FROM debian:bookworm-slim
LABEL maintainer="admin@based.pt"
ARG PUID=1000
ENV USER steam
ENV HOMEDIR "/home/${USER}"
ENV STEAMCMDDIR "${HOMEDIR}/steamcmd"
ARG PUID=1000
ENV USER=steam \
HOMEDIR=/home/steam \
STEAMCMDDIR=/home/steam/steamcmd \
PORT=27015 \
DATADIR=/data
RUN set -x \
# Install, update & upgrade packages
&& apt-get update \
&& apt-get install -y --no-install-recommends --no-install-suggests \
lib32stdc++6=12.2.0-14+deb12u1 \
@ -22,9 +23,9 @@ RUN set -x \
locales=2.36-9+deb12u13 \
&& sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen \
&& dpkg-reconfigure --frontend=noninteractive locales \
# Create unprivileged user
&& useradd -u "${PUID}" -m "${USER}" \
# Download SteamCMD, execute as user
&& mkdir -p "${STEAMCMDDIR}" "${DATADIR}" \
&& chown -R "${USER}:${USER}" "${HOMEDIR}" "${DATADIR}" \
&& su "${USER}" -c \
"mkdir -p \"${STEAMCMDDIR}\" \
&& curl -fsSL 'https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz' | tar xvzf - -C \"${STEAMCMDDIR}\" \
@ -37,34 +38,14 @@ RUN set -x \
&& ln -s \"${STEAMCMDDIR}/linux64/steamclient.so\" \"${HOMEDIR}/.steam/sdk64/steamclient.so\" \
&& ln -s \"${STEAMCMDDIR}/linux64/steamcmd\" \"${STEAMCMDDIR}/linux64/steam\" \
&& ln -s \"${STEAMCMDDIR}/steamcmd.sh\" \"${STEAMCMDDIR}/steam.sh\"" \
# Symlink steamclient.so; So misconfigured dedicated servers can find it
&& ln -s "${STEAMCMDDIR}/linux64/steamclient.so" "/usr/lib/x86_64-linux-gnu/steamclient.so" \
&& rm -rf /var/lib/apt/lists/*
FROM build_stage AS steamcmd
###########################################################
# HALF-LIFE SERVER
##########################################################
FROM steamcmd AS hlds
# Define variables
ENV STEAMAPPID 90
ENV STEAMAPPDIR "data/hlds"
ENV PORT 27015
USER ${USER}
WORKDIR ${HOMEDIR}
# Install Half-Life Dedicated Server (HLDS) for Counter-Strike
RUN mkdir -p ${STEAMAPPDIR} \
&& ${STEAMCMDDIR}/steamcmd.sh +force_install_dir ${STEAMAPPDIR} +login anonymous +app_update 90 +quit
EXPOSE ${PORT}/udp
VOLUME ["/data"]
# Expose necessary ports for the game
EXPOSE ${PORT}
# Run HLDS with the Counter-Strike mod
ENTRYPOINT ["${STEAMAPPDIR}/hlds_run", "-game", "cstrike", "-console", "-port", "${PORT}", "-steam_dir", "${STEAMCMDDIR}", "-steamcmd_script", "${STEAMCMDDIR}/steamcmd.sh"]
ENTRYPOINT ["/bin/bash", "-c", "/home/steam/steamcmd/steamcmd.sh +force_install_dir /data +login anonymous +app_set_config 90 mod cstrike +app_update 90 validate +quit && cd /data && exec bash hlds_run -game cstrike -console +ip 0.0.0.0 -port ${PORT}"]

View file

@ -4,8 +4,11 @@ services:
counter-strike:
build: .
container_name: counter-strike
stop_signal: SIGKILL
ports:
- "27016:27015/udp"
- "27016:27016/udp"
environment:
- PORT=27016
volumes:
- ./data:/data
restart: always