diff --git a/Backup.ps1 b/Backup.ps1 index 6e383ba..60be827 100644 --- a/Backup.ps1 +++ b/Backup.ps1 @@ -24,6 +24,8 @@ $itemsToBackup = @( "/minecraft/spigot.yml", "/minecraft/usercache.json", "/minecraft/whitelist.json", + "/minecraft/version_history.json", + "/minecraft/config", "/minecraft/world", "/minecraft/world_nether", "/minecraft/world_the_end" @@ -33,7 +35,7 @@ foreach ($item in $itemsToBackup) { $itemName = [System.IO.Path]::GetFileName($item) $destination = "$backupDir/$itemName" Write-Host "Backing up $item to $destination" - if ($item -like "*/world*" -or $item -eq "/minecraft/world" -or $item -eq "/minecraft/world_nether" -or $item -eq "/minecraft/world_the_end") { + if ($item -like "*/world*" -or $item -like "*/config*") { Write-Host "Backing up directory $item" docker cp "$($containerName):$($item)" "$($backupDir)/" } else { diff --git a/Build.ps1 b/Build.ps1 index b647d43..de34784 100644 --- a/Build.ps1 +++ b/Build.ps1 @@ -1,5 +1,5 @@ $containerName = "minecraft-server" -$imageName = "minecraft-spigot:latest" +$imageName = "minecraft-paper:latest" $container = docker ps -a --filter "name=$containerName" --format "{{.ID}}" if ($container) { diff --git a/Dockerfile b/Dockerfile index 4496f0d..550d0b2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,31 +1,25 @@ FROM ubuntu:latest AS builder -# Install Spigot dependencies -# This installs normal dependencies, sets up zulu apt repository and installs zulu21-jdk +# Install Paper dependencies RUN apt-get update && apt-get install -y \ curl \ - git \ wget \ + jq \ bash \ gnupg \ ca-certificates \ - && curl -s https://repos.azul.com/azul-repo.key | gpg --dearmor -o /usr/share/keyrings/azul.gpg \ - && echo "deb [signed-by=/usr/share/keyrings/azul.gpg] https://repos.azul.com/zulu/deb stable main" | tee /etc/apt/sources.list.d/zulu.list \ - && apt-get update && apt-get install -y zulu21-jdk + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* WORKDIR /minecraft -# Setup spigot.jar -# This downloads BuildTools.jar and uses that to build a new spigot.jar -RUN mkdir buildtools \ - && cd buildtools \ - && wget https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar \ - && java -jar BuildTools.jar --rev latest \ - && mv spigot-*.jar /minecraft/spigot.jar \ - && rm -rf /minecraft/buildtools +# Fetch the latest PaperMC version and build dynamically +RUN PAPER_VERSION=$(curl -s https://papermc.io/api/v2/projects/paper | jq -r '.versions[-1]') \ + && PAPER_BUILD=$(curl -s https://papermc.io/api/v2/projects/paper/versions/$PAPER_VERSION | jq -r '.builds[-1]') \ + && wget -O paper.jar https://papermc.io/api/v2/projects/paper/versions/$PAPER_VERSION/builds/$PAPER_BUILD/downloads/paper-$PAPER_VERSION-$PAPER_BUILD.jar # Accept EULA -RUN echo "eula=true" > /minecraft/eula.txt +RUN echo "eula=true" > eula.txt FROM alpine:latest AS runner @@ -33,9 +27,17 @@ COPY --from=builder /minecraft /minecraft RUN apk add --no-cache openjdk21-jre eudev +RUN addgroup -S mcgroup && adduser -S mcuser -G mcgroup -s /bin/sh \ + && chown -R mcuser:mcgroup /minecraft \ + && chmod g+s /minecraft + WORKDIR /minecraft -# Move spigot to server directory EXPOSE 25565 -CMD /bin/sh -c "java -Xmx2G -Xms512M -jar /minecraft/spigot.jar nogui > /minecraft/logs/output.log 2> /minecraft/logs/error.log" \ No newline at end of file +CMD /bin/sh -c ' \ + echo Fixing ownership of minecraft directory... && \ + chown -R mcuser:mcgroup /minecraft && \ + echo Starting minecraft server as mcuser && \ + su - mcuser -c "cd /minecraft/ && java -Xmx2G -Xms512M -jar /minecraft/paper.jar nogui" && \ + sleep 1727313' > /minecraft/logs/stdout.log 2> /minecraft/logs/stderr.log \ No newline at end of file diff --git a/Restore.ps1 b/Restore.ps1 index 45fadbe..a0daefb 100644 --- a/Restore.ps1 +++ b/Restore.ps1 @@ -32,6 +32,8 @@ $itemsToRestore = @( "spigot.yml", "usercache.json", "whitelist.json", + "version_history.json", + "config", "world", "world_nether", "world_the_end" diff --git a/Start.ps1 b/Start.ps1 index d808f7e..dfe3b6b 100644 --- a/Start.ps1 +++ b/Start.ps1 @@ -1,5 +1,5 @@ $containerName = "minecraft-server" -$imageName = "minecraft-spigot:latest" +$imageName = "minecraft-paper:latest" $container = docker ps -a --filter "name=$containerName" --format "{{.ID}}" if ($container) { @@ -17,7 +17,7 @@ if ($container) { -v "$(pwd)/plugins:/minecraft/plugins" ` -v "$(pwd)/logs:/minecraft/logs" ` --restart unless-stopped ` - minecraft-spigot + minecraft-paper Write-Host "Starting the container '$containerName'..." docker start $containerName