add minecraft version as env at runtime

This commit is contained in:
Bryson Steck 2025-08-10 12:50:22 -06:00
parent 878c146203
commit f642050104
Signed by: bryson
SSH key fingerprint: SHA256:XpKABw/nP4z8UVaH+weLaBnEOD86+cVwif+QjuYLGT4
2 changed files with 3 additions and 2 deletions

View file

@ -20,7 +20,7 @@ ARG MINECRAFT_VERSION="1.20.6"
RUN apk add --no-cache --upgrade rcon eudev-libs
WORKDIR /
COPY ./run-server /usr/local/bin/
RUN sed -i "s|VERSION|${MINECRAFT_VERSION}|g" /usr/local/bin/run-server
RUN sed -i "s|SED_VERSION|${MINECRAFT_VERSION}|g" /usr/local/bin/run-server
ARG UID="1000"
ARG GID="1000"
RUN adduser -D -H -u $UID -h /tmp user

View file

@ -1,4 +1,5 @@
#!/bin/sh
export MINECRAFT_VERSION=SED_VERSION
cleanup() {
rcon -m -p 25575 --host localhost --password "${MC_RCON_PASSWORD}" say Warning! Server is shutting down in 5 seconds...
@ -10,7 +11,7 @@ cd /server
envsubst < /spigot/server.properties.in > /server/server.properties
[ "$ACCEPT_EULA" = "true" ] && echo eula=true > /server/eula.txt
java -Xmx${SERVER_MEMORY:-6G} -jar /spigot/spigot-VERSION.jar nogui &
java -Xmx${SERVER_MEMORY:-6G} -jar /spigot/spigot-SED_VERSION.jar nogui &
trap "cleanup" INT
# wait twice in the event sigint (docker stop) is received