Skip to content

Commit

Permalink
fix root user as default for app (#9)
Browse files Browse the repository at this point in the history
- fix #8
  • Loading branch information
SergeyShorokhov authored Apr 4, 2024
2 parents 3e8d102 + 7d2677b commit 73d24ad
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
ARG APPDIR="/root/hlds"
ARG APPID="90"
ARG MOD="valve"

FROM debian:trixie-slim AS build_stage

ARG APPDIR
ARG APPID
ARG MOD
ARG APPBRANCH=""
Expand All @@ -25,21 +23,23 @@ ARG DepotDownloader_URL="https://github.com/SteamRE/DepotDownloader/releases/dow
RUN curl -L# ${DepotDownloader_URL} | bsdtar -xvf - -C /usr/local/bin/ \
&& chmod +x /usr/local/bin/DepotDownloader

ENV APPDIR=/root/hlds
WORKDIR ${APPDIR}

COPY --chmod=755 utils/* utils/

# Download mod depots
RUN DEPOTS=$(utils/getDepotsByMod.sh ${MOD}) \
&& for depot in ${DEPOTS}; do \
DepotDownloader -dir ${APPDIR} -app ${APPID} -depot ${depot} -beta ${APPBRANCH}; \
done \
&& rm -rf ${APPDIR}/.DepotDownloader
done

# Fix first run crash and STEAM Validation rejected issue
RUN cp ${APPDIR}/${MOD}/steam_appid.txt ${APPDIR}

# Remove unnecessary files
RUN rm -rf ${APPDIR}/linux64 \
&& find ${APPDIR} \( \
RUN rm -rf linux64 .DepotDownloader utils/ \
&& find . \( \
-name '*64.so' -o \
-name '*.dll' -o \
-name '*.dylib' \
Expand All @@ -56,22 +56,28 @@ RUN set -x \
lib32stdc++6=14-20240201-3 \
&& rm -rf /var/lib/apt/lists/*

ARG APPDIR
ARG APPUSER="hlds_user"
ENV APPUSER=${APPUSER}
ENV APPDIRNAME="hlds"

# Create a new user
RUN useradd -m -s /bin/bash ${APPUSER}
USER ${APPUSER}

# Copy HLDS files from build stage
COPY --from=build_stage ${APPDIR} ${APPDIR}
COPY --chown=${APPUSER}:${APPUSER} --from=build_stage /root/hlds home/${APPUSER}/${APPDIRNAME}

# Create symbolic links for steamclient.so
RUN mkdir -p ~/.steam/sdk32/ \
&& ln -s ${APPDIR}/steamclient.so ~/.steam/sdk32/steamclient.so \
&& ln -s ${APPDIR}/steamclient.so ${APPDIR}/steamservice.so

WORKDIR ${APPDIR}
RUN mkdir -p ${HOME}/.steam/sdk32/ \
&& ln -s ${HOME}/${APPDIRNAME}/steamclient.so /home/${APPUSER}/.steam/sdk32/steamclient.so \
&& ln -s ${HOME}/${APPDIRNAME}/steamclient.so ${HOME}/${APPDIRNAME}/steamservice.so

EXPOSE 26900-27020/udp

ARG MOD
ENV MOD=${MOD}

WORKDIR /home/${APPUSER}/${APPDIRNAME}

# Set default command
CMD ["sh", "-c", "./hlds_run -game ${MOD} +ip 0.0.0.0 -port 27016 +map $(head -n 1 ./${MOD}/mapcycle.txt)"]
CMD ["bash", "-c", "./hlds_run -game ${MOD} +ip 0.0.0.0 -port 27016 +map $(head -n 1 ./${MOD}/mapcycle.txt)"]

0 comments on commit 73d24ad

Please sign in to comment.