diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6c81359 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ + +# Ignore all assets in data folder except for template, etc. +data/* +!data/_placeholder +!data/ringserv-template.cfg +!data/addons/_placeholder \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 64d77b5..5939cfb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,6 @@ -FROM alpine:3 +FROM alpine:3.21 + +ARG RR_VERSION # Install Essential Utilities RUN apk update @@ -25,8 +27,12 @@ RUN ./build.sh # After building WORKDIR /home/ringracers +COPY --chown=ringracers:ringracers run_server.sh . +RUN chmod +x run_server.sh +COPY --chown=ringracers:ringracers ringserv-template.cfg ./server # Set up environment variables ENV RINGRACERSWADDIR=/data/ringracers-data +ENV RR_VERSION=${RR_VERSION} -ENTRYPOINT [ "server/ringracers_v2.3", "-dedicated" ] \ No newline at end of file +ENTRYPOINT [ "./run_server.sh" ] \ No newline at end of file diff --git a/build.sh b/build.sh index c2b0f15..7ef9d1e 100644 --- a/build.sh +++ b/build.sh @@ -1,13 +1,12 @@ #! /bin/bash -RR_VERSION=2,3 BUILDDIR=/buildfiles/RingRacers OUTDIR=/home/ringracers/server cd $BUILDDIR git fetch --tags -git switch --detach tags/v2.3 +git switch --detach tags/$RR_VERSION cmake --preset ninja-release cmake --build --preset ninja-release [[ -d $OUTDIR ]] || mkdir $OUTDIR -cp build/ninja-release/bin/ringracers_v2.3 $OUTDIR +cp build/ninja-release/bin/ringracers_$RR_VERSION $OUTDIR diff --git a/compose.yml b/compose.yml index e50a3a9..2ccf549 100644 --- a/compose.yml +++ b/compose.yml @@ -1,10 +1,23 @@ -version: '3' services: - ringracers: + main-server: + tty: true + stdin_open: true + restart: unless-stopped build: context: . dockerfile: Dockerfile + args: + - RR_VERSION=v2.3 ports: - 5029:5029/udp volumes: - - ./data:/data/ringracers-data \ No newline at end of file + - ./data:/data/ringracers-data + addons-server: + restart: unless-stopped + build: + context: nginx + dockerfile: Dockerfile + ports: + - 8080:80/tcp + volumes: + - ./data/addons:/data:ro \ No newline at end of file diff --git a/data/addons/_placeholder b/data/addons/_placeholder new file mode 100644 index 0000000..9832fd4 --- /dev/null +++ b/data/addons/_placeholder @@ -0,0 +1 @@ +Put all of the mods here \ No newline at end of file diff --git a/nginx/Dockerfile b/nginx/Dockerfile new file mode 100644 index 0000000..c6c8a4f --- /dev/null +++ b/nginx/Dockerfile @@ -0,0 +1,3 @@ +FROM nginx:1.27-alpine +EXPOSE 80 +COPY nginx.conf /etc/nginx/nginx.conf \ No newline at end of file diff --git a/nginx/nginx.conf b/nginx/nginx.conf new file mode 100644 index 0000000..1a26559 --- /dev/null +++ b/nginx/nginx.conf @@ -0,0 +1,12 @@ + +events {} +http { + server { + listen 80; + + location / { + root /data; + autoindex on; + } + } +} \ No newline at end of file diff --git a/ringserv-template.cfg b/ringserv-template.cfg new file mode 100644 index 0000000..cc129a1 --- /dev/null +++ b/ringserv-template.cfg @@ -0,0 +1,11 @@ + +servername "My Cool Server" +server_contact "" +password "" +http_source "http://:8080/" + +maxplayers MAX +maxconnections MAX +bots MAX +gamespeed 0 +randommap diff --git a/run_server.sh b/run_server.sh new file mode 100644 index 0000000..f14b32e --- /dev/null +++ b/run_server.sh @@ -0,0 +1,11 @@ +#! /bin/bash +RR_DOTFILES=/home/ringracers/.ringracers +SERVER_DIR=/home/ringracers/server + +# Create new config from template and add the nginx server +[[ -d $RR_DOTFILES ]] || mkdir $RR_DOTFILES +cp $SERVER_DIR/ringserv-template.cfg $RR_DOTFILES/ringserv.cfg + +# Load addons and start the game +find $RINGRACERSWADDIR/addons \( -name "*.pk3" -o -name "*.wad" -o -name "*.zip" \) \ + | xargs $SERVER_DIR/ringracers_${RR_VERSION} -dedicated -file \ No newline at end of file