From 0f8d559b178abd2cb9254e4b57025797f8ed955a Mon Sep 17 00:00:00 2001 From: Jerry Aldrich Date: Tue, 28 Jan 2020 22:06:14 -0800 Subject: [PATCH] Initial commit --- Dockerfile | 39 +++++++++++++++++++++++++++++++++++ README.md | 3 +++ WIP/chocolate-doom/Dockerfile | 18 ++++++++++++++++ WIP/chocolate-doom/README.md | 7 +++++++ WIP/odamex/Dockerfile | 39 +++++++++++++++++++++++++++++++++++ WIP/odamex/README.md | 6 ++++++ WIP/odamex/build_odamex.sh | 16 ++++++++++++++ WIP/odamex/odasrv.cfg | 2 ++ entrypoint.sh | 27 ++++++++++++++++++++++++ extract_server.sh | 12 +++++++++++ server.cfg | 10 +++++++++ 11 files changed, 179 insertions(+) create mode 100644 Dockerfile create mode 100644 README.md create mode 100644 WIP/chocolate-doom/Dockerfile create mode 100644 WIP/chocolate-doom/README.md create mode 100644 WIP/odamex/Dockerfile create mode 100644 WIP/odamex/README.md create mode 100755 WIP/odamex/build_odamex.sh create mode 100644 WIP/odamex/odasrv.cfg create mode 100755 entrypoint.sh create mode 100644 extract_server.sh create mode 100644 server.cfg diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d222d4d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,39 @@ +FROM debian:stable-slim + +RUN apt-get update -y && apt-get install -y wget bzip2 libsdl1.2debian unzip + +WORKDIR /src + +# Download and extract soruce +RUN wget https://zandronum.com/downloads/zandronum3.0-linux-x86_64.tar.bz2 +RUN tar xjf zandronum*.tar.bz2 + +# Extract libs used by server +RUN mkdir -p /export/libs +COPY extract_server.sh . +RUN bash ./extract_server.sh zandronum-server /export/libs +RUN cp libcrypto* /export/libs + +# Copy server and required files to /export +RUN cp zandronum-server zandronum.pk3 /export/ + +# Download FreeDM WAD +RUN wget https://github.com/freedoom/freedoom/releases/download/v0.12.1/freedm-0.12.1.zip +RUN unzip freed*.zip +RUN cd freedm* && cp freedm.wad /export + +# Libraries that aren't in busybox or alpines musl are needed :( +FROM debian:stable-slim + +EXPOSE 10666/udp + +RUN mkdir -p /srv +COPY --from=0 /export /srv +COPY server.cfg /srv +COPY entrypoint.sh /srv + +RUN useradd -m zandronum +RUN chown -R zandronum /srv +USER zandronum + +ENTRYPOINT /srv/entrypoint.sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..bb2669d --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Docker Doom Server + +See WIP/ for other nearly finished attempts of other servers diff --git a/WIP/chocolate-doom/Dockerfile b/WIP/chocolate-doom/Dockerfile new file mode 100644 index 0000000..b704d0d --- /dev/null +++ b/WIP/chocolate-doom/Dockerfile @@ -0,0 +1,18 @@ +FROM debian:stable-slim + +RUN apt-get update -y && apt-get install -y chocolate-doom + +RUN apt-get clean autoclean && apt-get autoremove --yes && rm -rf /var/lib/{apt,dpkg,cache,log}/ + +RUN mkdir -p /export/libs + +COPY extract_server.sh / +RUN bash /extract_server.sh /usr/games/chocolate-server /export/libs + +FROM debian:stable-slim + +COPY --from=0 /export /srv + +EXPOSE 10666/udp + +CMD LD_LIBRARY_PATH=/srv/libs /srv/chocolate-server -privateserver -port 10666 diff --git a/WIP/chocolate-doom/README.md b/WIP/chocolate-doom/README.md new file mode 100644 index 0000000..ef98140 --- /dev/null +++ b/WIP/chocolate-doom/README.md @@ -0,0 +1,7 @@ +# Chocolate Doom + +Chocolate Doom is neat for it's retro appeal, but it doesn't really work +outside of a LAN party imo. I eventually went with Zandronum due to it's Linux +support and modern online play capabilities. + +If you want to build this make sure you copy in extract_server.sh from above. diff --git a/WIP/odamex/Dockerfile b/WIP/odamex/Dockerfile new file mode 100644 index 0000000..1557290 --- /dev/null +++ b/WIP/odamex/Dockerfile @@ -0,0 +1,39 @@ +# Switch to alpine to serve content built above +FROM ubuntu:latest + +RUN apt-get update -y +RUN apt-get install -y cmake wget g++ unzip + +RUN mkdir /src + +WORKDIR /src + +RUN wget https://github.com/odamex/odamex/archive/0.8.1.tar.gz +RUN tar xvzf *.tar.gz + +COPY build_odamex.sh /build_odamex.sh +RUN /build_odamex.sh + +RUN wget https://github.com/freedoom/freedoom/releases/download/v0.12.1/freedm-0.12.1.zip +RUN unzip freedm*.zip +RUN cp freedm*/freedm.wad /export + +# Using debian slim as opposed to alpine because +# odamex uses libraries only available in glibc +FROM debian:stable-slim + +COPY --from=0 /export/odasrv /srv/odasrv +COPY --from=0 /export/odamex.wad /srv/odamex.wad +COPY --from=0 /export/freedm.wad /srv/freedm.wad +COPY odasrv.cfg /srv/odasrv.cfg + +# RUN useradd --no-create-home --shell /bin/false odamex +RUN useradd -m --shell /bin/false odamex + +RUN chown -R odamex:odamex /srv/ + +USER odamex + +CMD /srv/odasrv -config /srv/odasrv.cfg + +EXPOSE 10666/udp diff --git a/WIP/odamex/README.md b/WIP/odamex/README.md new file mode 100644 index 0000000..be079da --- /dev/null +++ b/WIP/odamex/README.md @@ -0,0 +1,6 @@ +# Docker Odamex + +You can use this to build a Odamex Doom server. + +I put a lot of work into this, but ultimately went with Zandronum due to it's +compatibility with Linux. I couldn't get audio working with Odamex :( diff --git a/WIP/odamex/build_odamex.sh b/WIP/odamex/build_odamex.sh new file mode 100755 index 0000000..935a9f6 --- /dev/null +++ b/WIP/odamex/build_odamex.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +set -e + +cd /src/odamex* + +mkdir /export + +cp odamex.wad /export + +mkdir build +cd build && cmake .. -DCMAKE_BUILD_TYPE=MinSizRel -DBUILD_CLIENT=0 -DBUILD_ODALAUNCH=0 + +make odasrv + +cp server/odasrv /export diff --git a/WIP/odamex/odasrv.cfg b/WIP/odamex/odasrv.cfg new file mode 100644 index 0000000..ddd4945 --- /dev/null +++ b/WIP/odamex/odasrv.cfg @@ -0,0 +1,2 @@ +sv_usemasters 0 + diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..1edd96f --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +set -e + +BOT_COUNT=${BOT_COUNT:-0} + +if [ -n "$SV_HOSTNAME" ]; then + echo "set sv_hostname $SV_HOSTNAME" >> /srv/server.cfg +fi + +if [ -n "$RCON_PASSWORD" ]; then + echo "set sv_rconpassword $RCON_PASSWORD" >> /srv/server.cfg +fi + +# As of Zandrodum 3.0.0 we have to use `+addbot` instead using server.cfg +# https://zandronum.com/forum/viewtopic.php?t=8073 +ADDBOT_CMDS="" +for _ in $(seq $BOT_COUNT); do + ADDBOT_CMDS+='+addbot "" ' +done + +PORT=${PORT:-10666} + +GAMETYPE=${GAMETYPE:-Deathmatch} + +SV_ARGS="+exec server.cfg -port $PORT $ADDBOT_CMDS +$GAMETYPE true" +cd /srv/ && LD_LIBRARY_PATH=libs sh -c "./zandronum-server $SV_ARGS" diff --git a/extract_server.sh b/extract_server.sh new file mode 100644 index 0000000..e92c109 --- /dev/null +++ b/extract_server.sh @@ -0,0 +1,12 @@ +# Many thanks to https://www.h3manth.com/content/copying-shared-library-dependencies + +set -e + +cp $1 /export + +deps=$(ldd $1 | awk 'BEGIN{ORS=" "}$1~/^\//{print $1}$3~/^\//{print $3}' | sed 's/,$/\n/') + +for dep in $deps; do + echo "Copying $dep to $2" + cp "$dep" "$2" +done diff --git a/server.cfg b/server.cfg new file mode 100644 index 0000000..70b300f --- /dev/null +++ b/server.cfg @@ -0,0 +1,10 @@ +// https://wiki.zandronum.com/Server_Variables + +// Disable mouselook +set sv_nofreelook true + +// Timestamp console messages +set sv_timestamp true + +// Prepend CHAT to all chat messages in the log +set sv_markchatlines true