From eeb5f95f9157f706f9e0056937181e2faa7fe497 Mon Sep 17 00:00:00 2001 From: Marc Baloup Date: Thu, 8 Dec 2022 15:18:19 +0100 Subject: [PATCH] Improved build and run --- Dockerfile | 21 +++++++++------------ build.sh | 6 +++--- run.sh | 11 +++++++++++ 3 files changed, 23 insertions(+), 15 deletions(-) create mode 100644 run.sh diff --git a/Dockerfile b/Dockerfile index f9b69f6..8c50439 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,25 +2,22 @@ FROM eclipse-temurin:17-jdk ARG RUNNABLE_SERVER_JAR +# create directories WORKDIR /data -RUN mkdir jar bundle workdir +RUN mkdir bin bundle workdir -ADD $RUNNABLE_SERVER_JAR jar/paper.jar +# add executable files +ADD $RUNNABLE_SERVER_JAR bin/paper.jar +ADD run.sh bin/run.sh -RUN java -DbundlerRepoDir=/data/bundle -Dpaperclip.patchonly=true -jar /data/jar/paper.jar +# download paper libraries and apply patches +RUN java -DbundlerRepoDir=/data/bundle -Dpaperclip.patchonly=true -jar /data/bin/paper.jar +# configure max heap size ENV MAXMEM=1024M EXPOSE 25565 VOLUME /data/workdir WORKDIR /data/workdir -CMD java -Xmx$MAXMEM -XX:+UseG1GC -XX:+ParallelRefProcEnabled \ - -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions \ - -XX:G1ReservePercent=15 -XX:G1NewSizePercent=20 -XX:G1MaxNewSizePercent=30 \ - -XX:G1HeapRegionSize=8M -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 \ - -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 \ - -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 \ - -XX:MaxHeapFreeRatio=30 -XX:MinHeapFreeRatio=5 \ - -DbundlerRepoDir=/data/bundle \ - -jar /data/jar/paper.jar nogui +CMD ["sh", "/data/bin/run.sh"] diff --git a/build.sh b/build.sh index f383226..8cb6fb8 100644 --- a/build.sh +++ b/build.sh @@ -50,11 +50,11 @@ curl -o $RUNNABLE_SERVER_JAR $DOWNLOAD_REOBF DOCKER_TAG="pandacubefr/paper:"$MC_VERSION"-"$PAPER_BUILD echo "Building docker image with pre-downloaded and pre-patched files, with tag "$DOCKER_TAG -docker build --build-arg RUNNABLE_SERVER_JAR=$RUNNABLE_SERVER_JAR -t $DOCKER_TAG . +docker build --build-arg RUNNABLE_SERVER_JAR=$RUNNABLE_SERVER_JAR -t $DOCKER_TAG -f Dockerfile.paper . -DOCKER_IMAGE_FILE="Paper-docker-image-"$MC_VERSION"-"$PAPER_BUILD".tar.gz" +DOCKER_IMAGE_FILE="Paper-docker-"$MC_VERSION"-"$PAPER_BUILD".tar.gz" echo "Saving docker image to "$DOCKER_IMAGE_FILE -docker save -o $DOCKER_IMAGE_FILE $DOCKER_TAG +docker save $DOCKER_TAG | gzip > $DOCKER_IMAGE_FILE #mkdir uberjar #for jar in `cat jars.txt`; do diff --git a/run.sh b/run.sh new file mode 100644 index 0000000..d150a6d --- /dev/null +++ b/run.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +java -Xmx$MAXMEM -XX:+UseG1GC -XX:+ParallelRefProcEnabled \ + -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions \ + -XX:G1ReservePercent=15 -XX:G1NewSizePercent=20 -XX:G1MaxNewSizePercent=30 \ + -XX:G1HeapRegionSize=8M -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 \ + -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 \ + -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 \ + -XX:MaxHeapFreeRatio=30 -XX:MinHeapFreeRatio=5 \ + -DbundlerRepoDir=/data/bundle \ + -jar /data/bin/paper.jar nogui