Skip to content

Commit

Permalink
docs: improve comments in DockerFile to explain whats going on better
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesIves committed Oct 2, 2024
1 parent fca1a8d commit 7d95e48
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions container/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ FROM ubuntu:18.04

# Sets an environment variable for the game to install.
# Supported games: valve, cstrike, czero, dod, dmc, gearbox, ricochet, tfc
# Default is valve. This get replaced when building the image with --build-arg GAME=<game>
# Default is valve. This gets replaced when building the image with --build-arg GAME=<game>
ARG GAME=valve
ENV GAME ${GAME}

# Sets an environment variable for any additional flag that should be passed to the SteamCMD installer.
# Default is an empty string. This get replaced when building the image with --build-arg FLAG=<FLAG>
# Default is an empty string. This gets replaced when building the image with --build-arg FLAG=<FLAG>
# For example, you may set this to "-beta steam_legacy".
ARG FLAG
ENV FLAG ${FLAG}
Expand All @@ -31,27 +31,33 @@ LABEL org.opencontainers.image.documentation="https://github.com/jamesives/hlds-
LABEL org.opencontainers.image.source="https://github.com/jamesives/hlds-docker"
LABEL org.opencontainers.image.version="${VERSION}"

# Installs the necessary dependencies for the SteamCMD installer.
RUN dpkg --add-architecture i386 && \
apt-get update && \
apt-get install -y --no-install-recommends curl rsync file libc6:i386 lib32stdc++6 ca-certificates && \
rm -rf /var/lib/apt/lists/*

# Creates a new user and group for the SteamCMD installer.
RUN groupadd -r steam && \
useradd -r -g steam -m -d /opt/steam steam

# Creates the necessary directories for the Half-Life Dedicated Server.
RUN mkdir /config
RUN mkdir /mods

# Sets the user to the steam user.
USER steam
WORKDIR /opt/steam

# Copies the hlds.txt file to the container.
COPY ./hlds.txt /opt/steam

# Replaces $GAME with the requested mod to install in hlds.txt.
# Additionally replaces $FLAG with any additional FLAG that should be passed to the SteamCMD installer to support betas.
# Additionally replaces $FLAG with any additional flags that should be passed to the SteamCMD installer to support betas.
RUN sed -i "s/\$GAME/${GAME}/g" /opt/steam/hlds.txt
RUN sed -i "s/\$FLAG/${FLAG}/g" /opt/steam/hlds.txt

# Downloads and extracts the SteamCMD installer.
RUN curl -v -sL media.steampowered.com/client/installer/steamcmd_linux.tar.gz | tar xzvf - && \
file /opt/steam/linux32/steamcmd && \
./steamcmd.sh +runscript /opt/steam/hlds.txt
Expand All @@ -62,12 +68,15 @@ RUN mkdir -p $HOME/.steam \
&& ln -s /opt/steam/linux32 $HOME/.steam/sdk32 \
&& echo 70 > /opt/steam/hlds/steam_appid.txt


WORKDIR /opt/steam/hlds

# Copies the entrypoint script to the container and sets the necessary permissions.
COPY --chown=steam:steam ./entrypoint.sh ./entrypoint.sh
COPY --chown=steam:steam config $GAME
COPY --chown=steam:steam mods .

# Sets the entrypoint script as executable.
RUN chmod +x ./entrypoint.sh


Expand Down

0 comments on commit 7d95e48

Please sign in to comment.