mirror of
https://github.com/AlexMacocian/Docker-Minecraft-Paper.git
synced 2026-07-15 15:19:32 +00:00
Switch to paper
Run as non-priviledged user Fix Restore and Backup
This commit is contained in:
+3
-1
@@ -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 {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
+19
-17
@@ -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"
|
||||
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
|
||||
@@ -32,6 +32,8 @@ $itemsToRestore = @(
|
||||
"spigot.yml",
|
||||
"usercache.json",
|
||||
"whitelist.json",
|
||||
"version_history.json",
|
||||
"config",
|
||||
"world",
|
||||
"world_nether",
|
||||
"world_the_end"
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user