modified Dockerfile to use multi-stage building for best practice with layering

This commit is contained in:
Brett Caswell 2020-02-27 14:56:25 -06:00
parent 1a29555c96
commit 94ffe468f8

View file

@ -1,17 +1,27 @@
FROM ubuntu FROM ubuntu AS Ubuntu_SteamCMD
# Get Package Dependencies, Accept ToS with Steam Dependency, clear appt cache
RUN dpkg --add-architecture i386 && \ RUN dpkg --add-architecture i386 && \
apt-get update && \ apt-get update && \
apt-get -y install wget lib32gcc1 lib32stdc++6 libcurl3:i386 unzip liblz4-tool gcc-multilib g++-multilib apt-get -y install wget \
lib32gcc1 \
# Accept ToS lib32stdc++6 \
RUN printf "\n2\n"|apt-get install -y steamcmd libstdc++6:i386 \
libcurl3:i386 \
unzip \
liblz4-tool \
gcc-multilib \
g++-multilib && \
printf "\n2\n"|apt-get install -y steamcmd && \
rm -rf /var/lib/apt/lists/*
RUN useradd -m steam RUN useradd -m steam
USER steam USER steam
WORKDIR /home/steam WORKDIR /home/steam
FROM Ubuntu_SteamCMD AS SteamCMD_HLDS
RUN mkdir -p /home/steam/hlds/steamapps/ RUN mkdir -p /home/steam/hlds/steamapps/
# Run app validate several times workaround HLDS bug # Run app validate several times workaround HLDS bug
@ -21,61 +31,54 @@ RUN /usr/games/steamcmd +login anonymous +force_install_dir /home/steam/hlds +ap
COPY --chown=steam files/*.acf /home/steam/hlds/steamapps/ COPY --chown=steam files/*.acf /home/steam/hlds/steamapps/
# HLDS bug workaround. Geez. # HLDS bug workaround. Geez.
RUN printf "quit\nquit\n"|/usr/games/steamcmd +login anonymous +force_install_dir /home/steam/hlds +app_set_config 90 mod valve +app_update 90 validate ||true RUN printf "quit\nquit\n"|/usr/games/steamcmd +login anonymous +force_install_dir /home/steam/hlds +app_set_config 90 mod valve +app_update 90 validate ||true && \
RUN printf "quit\nquit\n"|/usr/games/steamcmd +login anonymous +force_install_dir /home/steam/hlds +app_set_config 90 mod valve +app_update 90 validate ||true printf "quit\nquit\n"|/usr/games/steamcmd +login anonymous +force_install_dir /home/steam/hlds +app_set_config 90 mod valve +app_update 90 validate ||true && \
RUN printf "quit\nquit\nquit\nquit\nquit\n" |/usr/games/steamcmd +login anonymous +force_install_dir /home/steam/hlds +app_set_config 90 mod valve +app_update 90 validate ||true printf "quit\nquit\nquit\nquit\nquit\n" |/usr/games/steamcmd +login anonymous +force_install_dir /home/steam/hlds +app_set_config 90 mod valve +app_update 90 validate ||true
# HLDS bug workaround. Yay. # HLDS bug workaround. Yay.
RUN mkdir -p ~/.steam/sdk32 && ln -s ~/.steam/steamcmd/linux32/steamclient.so ~/.steam/sdk32/steamclient.so RUN mkdir -p ~/.steam/sdk32 && ln -s ~/.steam/steamcmd/linux32/steamclient.so ~/.steam/sdk32/steamclient.so
COPY scripts/*.sh /home/steam/hlds/
FROM SteamCMD_HLDS AS HLDS_NS
WORKDIR /home/steam/hlds WORKDIR /home/steam/hlds
COPY --chown=steam files/ns.sha /home/steam/hlds
# NS bug workaround. Since NS links to a GCC which is not included in the steam-provided libstdc++:i386 # NS bug workaround. Since NS links to a GCC which is not included in the steam-provided libstdc++:i386
RUN mv libstdc++* /home/steam/ RUN mv /home/steam/hlds/libstdc++* /home/steam/ && \
# Install NS # Install NS
RUN wget 'https://github.com/ENSL/NS/releases/download/v3.2.2/ns_v322_full.zip' wget 'https://github.com/ENSL/NS/releases/download/v3.2.2/ns_v322_full.zip' && \
COPY --chown=steam files/ns.sha /home/steam/hlds unzip ns_v322_full.zip && \
# RUN sha256sum -c ns.sha cp /home/steam/hlds/ns/liblist.gam /home/steam/hlds/ns/liblist.bak
RUN unzip ns_v322_full.zip
FROM HLDS_NS AS HLDS_ENSL
WORKDIR /home/steam/hlds/ns WORKDIR /home/steam/hlds/ns
# NS workarounds
RUN echo 70 > steam_appid.txt
# RUN mv dlls/ns_i386.so dlls/ns.so || echo
# ENSL package # ENSL package
RUN cp liblist.gam liblist.bak RUN wget https://github.com/ENSL/ensl-plugin/releases/download/1.4-extra/ENSL_SrvPkg-1.4-extra.zip -O srv.zip && \
# RUN wget https://github.com/ENSL/ensl-plugin/releases/download/v1.4/ensl_srvpkg-v1.4.zip -O srv.zip unzip -o srv.zip && \
RUN wget https://github.com/ENSL/ensl-plugin/releases/download/1.4-extra/ENSL_SrvPkg-1.4-extra.zip -O srv.zip
RUN unzip -o srv.zip
# Use seperate server.cfg because autoexec.cfg is unreliable # Use seperate server.cfg because autoexec.cfg is unreliable
RUN touch /home/steam/hlds/ns/server.cfg touch /home/steam/hlds/ns/server.cfg
# Copy own configs including bans # Copy own configs including bans
ADD overlay /home/steam/hlds/ns/ ADD overlay /home/steam/hlds/ns/
COPY scripts/*.sh /home/steam/hlds/
USER root #USER root
RUN chown -R steam /home/steam/hlds #RUN chown -R steam /home/steam/hlds
RUN apt-get install -y libstdc++6:i386 #USER steam
USER steam
WORKDIR /home/steam/hlds WORKDIR /home/steam/hlds
# VAC Service # VAC Service
EXPOSE 26900 EXPOSE 26900 \
# HLDS # HLDS
EXPOSE 27016 27016 \
# HLDS RCON # HLDS RCON
EXPOSE 27016/udp 27016/udp \
# HLTV # HLTV
EXPOSE 27020 27020
# ENTRYPOINT ["/bin/bash"] # ENTRYPOINT ["/bin/bash"]
ENTRYPOINT ["/home/steam/hlds/entry.sh"] ENTRYPOINT ["/home/steam/hlds/entry.sh"]