Fix Docker setup - download GMod at runtime

- Dockerfile now only installs SteamCMD, server downloaded on first run
- Entrypoint handles full server installation including addons
- Fixed volume configuration for persistence
- Added AUTO_UPDATE environment variable
This commit is contained in:
Vish
2026-01-19 06:44:41 +00:00
parent ce7fc9f39c
commit 82ad91ea4e
3 changed files with 126 additions and 68 deletions

View File

@@ -1,6 +1,8 @@
#===============================================================================
# Garry's Mod PropHunt Server - Docker Image
# Repository: https://git.vish.gg/Vish/gmod-prophunt-server
#
# This Dockerfile downloads GMod server at runtime for better compatibility
#===============================================================================
FROM debian:bookworm-slim
@@ -23,7 +25,8 @@ ENV DEBIAN_FRONTEND=noninteractive \
GAMEMODE="prop_hunt" \
WORKSHOP_COLLECTION="" \
TICKRATE="66" \
TZ="America/Los_Angeles"
TZ="America/Los_Angeles" \
AUTO_UPDATE="true"
# Install dependencies
RUN dpkg --add-architecture i386 && \
@@ -36,7 +39,6 @@ RUN dpkg --add-architecture i386 && \
unzip \
lib32gcc-s1 \
lib32stdc++6 \
libsdl2-2.0-0:i386 \
locales \
tzdata && \
sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
@@ -50,70 +52,32 @@ ENV LANG=en_US.UTF-8 \
# Create user and directories
RUN useradd -m -s /bin/bash gmod && \
mkdir -p ${SERVER_DIR} ${STEAMCMD_DIR} && \
mkdir -p /home/gmod/serverfiles /home/gmod/steamcmd && \
chown -R gmod:gmod /home/gmod
# Switch to gmod user
USER gmod
WORKDIR /home/gmod
# Install SteamCMD
RUN cd ${STEAMCMD_DIR} && \
curl -sqL "https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz" | tar zxvf -
# Install SteamCMD only (server downloaded at runtime)
RUN cd /home/gmod/steamcmd && \
curl -sqL "https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz" | tar zxvf - && \
./steamcmd.sh +quit
# Install Garry's Mod server
RUN cd ${STEAMCMD_DIR} && \
./steamcmd.sh +force_install_dir ${SERVER_DIR} \
+login anonymous \
+app_update 4020 validate \
+quit
# Install MetaMod:Source
RUN cd /tmp && \
METAMOD_VER=$(curl -s "https://mms.alliedmods.net/mmsdrop/1.11/" | grep -oP 'mmsource-[\d.]+-git\d+-linux\.tar\.gz' | tail -1) && \
wget -q "https://mms.alliedmods.net/mmsdrop/1.11/${METAMOD_VER}" -O metamod.tar.gz && \
tar -xzf metamod.tar.gz -C ${SERVER_DIR}/garrysmod/ && \
rm metamod.tar.gz
# Install SourceMod
RUN cd /tmp && \
SOURCEMOD_VER=$(curl -s "https://sm.alliedmods.net/smdrop/1.11/" | grep -oP 'sourcemod-[\d.]+-git\d+-linux\.tar\.gz' | tail -1) && \
wget -q "https://sm.alliedmods.net/smdrop/1.11/${SOURCEMOD_VER}" -O sourcemod.tar.gz && \
tar -xzf sourcemod.tar.gz -C ${SERVER_DIR}/garrysmod/ && \
rm sourcemod.tar.gz
# Install ULib and ULX
RUN cd /tmp && \
wget -q "https://github.com/TeamUlysses/ulib/archive/refs/heads/master.zip" -O ulib.zip && \
unzip -q ulib.zip -d ${SERVER_DIR}/garrysmod/addons/ && \
mv ${SERVER_DIR}/garrysmod/addons/ulib-master ${SERVER_DIR}/garrysmod/addons/ulib && \
rm ulib.zip && \
wget -q "https://github.com/TeamUlysses/ulx/archive/refs/heads/master.zip" -O ulx.zip && \
unzip -q ulx.zip -d ${SERVER_DIR}/garrysmod/addons/ && \
mv ${SERVER_DIR}/garrysmod/addons/ulx-master ${SERVER_DIR}/garrysmod/addons/ulx && \
rm ulx.zip
# Copy configuration files
COPY --chown=gmod:gmod cfg/ ${SERVER_DIR}/garrysmod/cfg/
# Copy configuration and entrypoint
COPY --chown=gmod:gmod cfg/ /home/gmod/cfg-template/
COPY --chown=gmod:gmod scripts/docker-entrypoint.sh /home/gmod/entrypoint.sh
# Make scripts executable
USER root
RUN chmod +x /home/gmod/entrypoint.sh ${SERVER_DIR}/srcds_run ${SERVER_DIR}/srcds_linux 2>/dev/null || true
RUN chmod +x /home/gmod/entrypoint.sh
USER gmod
# Expose ports
EXPOSE 27015/tcp 27015/udp 27005/udp 27020/udp
# Volumes for persistent data
VOLUME ["/home/gmod/serverfiles/garrysmod/data", \
"/home/gmod/serverfiles/garrysmod/cfg", \
"/home/gmod/serverfiles/garrysmod/addons"]
VOLUME ["/home/gmod/serverfiles"]
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=120s --retries=3 \
CMD curl -f http://localhost:27015/ 2>/dev/null || exit 1
WORKDIR ${SERVER_DIR}
WORKDIR /home/gmod
ENTRYPOINT ["/home/gmod/entrypoint.sh"]