feat: update server on start

This commit is contained in:
CyberL1 2024-12-19 15:08:41 +01:00
parent 0a89b6ade1
commit 484d12463a
2 changed files with 10 additions and 3 deletions

View File

@ -3,7 +3,7 @@ FROM eclipse-temurin:21-jre-alpine
COPY . .
RUN apk upgrade
RUN apk add openssl
RUN apk add openssl curl jq
RUN wget -O rcon-cli.tar.gz https://github.com/itzg/rcon-cli/releases/download/1.6.7/rcon-cli_1.6.7_linux_amd64.tar.gz
RUN tar xzf rcon-cli.tar.gz
@ -12,7 +12,6 @@ RUN rm rcon-cli.tar.gz
RUN mv rcon-cli /bin/rcon-cli
WORKDIR mc
RUN wget -O server.jar https://piston-data.mojang.com/v1/objects/450698d1863ab5180c25d7c804ef0fe6369dd1ba/server.jar
EXPOSE 25565
ENTRYPOINT ["/entrypoint"]

View File

@ -11,4 +11,12 @@ if [ ! -f server.properties ]; then
echo "level-name=slot-1" >> server.properties
fi
# Download latest server.jar
if [ ! -f .no-update ]; then
VERSION_URL=$(curl https://piston-meta.mojang.com/mc/game/version_manifest_v2.json | jq -r '.latest.release as $latest | .versions | to_entries[] | select(.value.id == $latest) | .value.url')
SERVER_URL=$(curl $VERSION_URL | jq -r .downloads.server.url)
wget -O server.jar $SERVER_URL
fi
java -jar server.jar