Multi-stage build

This commit is contained in:
mr-vercetti 2022-11-02 15:18:14 +01:00
parent ee5c898b47
commit 1af25be2f7

View File

@ -1,3 +1,10 @@
FROM mrvercetti/steamcmd as builder
# Download Sven Co-Op server
RUN ${STEAMCMD_DIR}/steamcmd.sh +login anonymous +force_install_dir ${OUTPUT_DIR} +app_update 276060 validate +quit && \
echo "225840" > ${OUTPUT_DIR}/steam_appid.txt
# Fresh start
FROM debian:stable-slim FROM debian:stable-slim
LABEL maintainer="mr-vercetti" LABEL maintainer="mr-vercetti"
@ -10,10 +17,10 @@ RUN dpkg --add-architecture i386 && \
locale-gen --no-purge en_US.UTF-8 && \ locale-gen --no-purge en_US.UTF-8 && \
apt-get clean && rm -rf /tmp/* /var/lib/apt/lists/* /var/tmp/* apt-get clean && rm -rf /tmp/* /var/lib/apt/lists/* /var/tmp/*
# General variables
ENV LANG=en_US.UTF-8 LANGUAGE=en_US.UTF-8 ENV LANG=en_US.UTF-8 LANGUAGE=en_US.UTF-8
ENV APP_DIR="/app" ENV SERVER_DIR="/svencoop-server"
ENV STEAMCMD_DIR="${APP_DIR}/Steam/steamcmd" ENV OUTPUT_DIR="/output"
ENV SERVER_DIR="${APP_DIR}/server"
# Startup variables # Startup variables
ENV GAME_PARAMS="-num_edicts 3072 +sv_lan 1 -port 27015 -console -debug;" ENV GAME_PARAMS="-num_edicts 3072 +sv_lan 1 -port 27015 -console -debug;"
ENV GAME_NAME="" ENV GAME_NAME=""
@ -21,26 +28,19 @@ ENV GAME_PASSWORD=""
# Set up user environment # Set up user environment
RUN groupadd -r abc && \ RUN groupadd -r abc && \
useradd -d ${APP_DIR} -r -g abc abc && \ useradd -d ${SERVER_DIR} -r -g abc abc && \
mkdir -p ${SERVER_DIR} ${STEAMCMD_DIR} && \ mkdir -p ${SERVER_DIR} && \
chown -R abc:abc ${APP_DIR} chown -R abc:abc ${SERVER_DIR}
ADD --chown=abc:abc --chmod=755 /scripts/start.sh /
USER abc USER abc
WORKDIR ${APP_DIR} WORKDIR ${SERVER_DIR}
# Download and update steamcmd # Copy needed files
RUN wget -qO- http://media.steampowered.com/installer/steamcmd_linux.tar.gz | tar xz -C ${STEAMCMD_DIR} && \ COPY --chown=abc:abc --chmod=755 /scripts/start.sh /
chmod +x ${STEAMCMD_DIR}/steamcmd.sh && \ COPY --chown=abc:abc --from=builder ${OUTPUT_DIR} ${SERVER_DIR}
${STEAMCMD_DIR}/steamcmd.sh +force_install_dir ${STEAMCMD_DIR} +login anonymous +quit
# Download Sven Co-Op server
RUN ${STEAMCMD_DIR}/steamcmd.sh +login anonymous +force_install_dir ${SERVER_DIR} +app_update 276060 validate +quit && \
echo "225840" > ${SERVER_DIR}/steam_appid.txt
# Link steamclient.so to prevent srcds_run errors # Link steamclient.so to prevent srcds_run errors
RUN mkdir -p ${APP_DIR}/.steam/sdk32 && \ RUN mkdir -p ${SERVER_DIR}/.steam/sdk32 && \
ln -s ${SERVER_DIR}/steamclient.so ${APP_DIR}/.steam/sdk32/steamclient.so ln -s ${SERVER_DIR}/steamclient.so ${SERVER_DIR}/.steam/sdk32/steamclient.so
ENTRYPOINT ["/start.sh"] ENTRYPOINT ["/start.sh"]