Skip to content

Commit ea06163

Browse files
committed
updated scripts
1 parent d7807d1 commit ea06163

File tree

4 files changed

+31
-37
lines changed

4 files changed

+31
-37
lines changed

Dockerfile

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,26 @@
1-
# ------- BUILD LAYER --------- #
2-
FROM alpine AS build
1+
FROM amazoncorretto:21
32

43
ARG mc_version
54
ENV MC_VERSION=${mc_version}
65

7-
RUN apk add --no-cache curl jq
8-
9-
COPY --chmod=755 install-paper.sh /tmp/install-paper.sh
10-
RUN /tmp/install-paper.sh
11-
12-
# -------- APP LAYER ---------- #
13-
FROM amazoncorretto:21
14-
156
ENV PUID=1000
16-
RUN yum install wget shadow-utils -y && useradd -r -u ${PUID} mc
17-
187
ENV GOSU_VERSION=1.17
19-
COPY --chmod=755 install-gosu.sh /tmp/install-gosu.sh
20-
RUN /tmp/install-gosu.sh
21-
22-
COPY --from=build --chmod=755 /tmp/server.jar /opt/minecraft/server.jar
238

249
# https://docs.papermc.io/paper/aikars-flags
2510
ENV JAVA_FLAGS="-Dlog4j2.formatMsgNoLookups=true -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=mcflags.emc.gs -Dcom.mojang.eula.agree=true"
2611
ENV PAPERMC_FLAGS="--nojline"
2712
ENV MEM_SIZE="1G"
2813

29-
WORKDIR /data
14+
VOLUME /opt/minecraft/data
15+
WORKDIR /opt/minecraft/data
16+
17+
COPY --chmod=755 ./install-gosu.sh ./install-paper.sh ./docker-entrypoint.sh /usr/local/bin/
18+
19+
RUN yum install -y curl wget jq shadow-utils && \
20+
useradd -r -u ${PUID} mc && \
21+
# mkdir -p /opt/minecraft && \
22+
install-gosu.sh && \
23+
install-paper.sh
3024

31-
COPY --chmod=755 docker-entrypoint.sh /docker-entrypoint.sh
32-
ENTRYPOINT ["/docker-entrypoint.sh"]
25+
ENTRYPOINT ["docker-entrypoint.sh"]
3326
CMD java -jar -Xms${MEM_SIZE} -Xmx${MEM_SIZE} ${JAVA_FLAGS} /opt/minecraft/server.jar ${PAPERMC_FLAGS} nogui

docker-entrypoint.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
#!/bin/sh
2-
set -eux
1+
#!/usr/bin/env sh
2+
set -e
33

44
if [ -n "${PUID}" ] && [ ! "${PUID}" = "$(id mc -u)" ]; then
55
usermod -o -u "$PUID" mc
66
echo "UID of mc user: $(id mc -u)"
77
fi
8-
chown -R mc /data
8+
9+
chown -R mc /opt/minecraft
910
exec gosu mc "$@"

install-gosu.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
#!/bin/sh
1+
#!/usr/bin/env sh
22
# https://github.com/tianon/gosu/blob/master/INSTALL.md
3-
set -eux
3+
set -e
4+
45
rpmArch="$(rpm --query --queryformat='%{ARCH}' rpm)";
56
case "$rpmArch" in
67
aarch64) dpkgArch='arm64' ;;
@@ -12,7 +13,9 @@ case "$rpmArch" in
1213
*) echo >&2 "error: unknown/unsupported architecture '$rpmArch'"; exit 1 ;;
1314
esac;
1415
echo "$rpmArch -> $dpkgArch"
16+
1517
wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch";
1618
chmod +x /usr/local/bin/gosu;
19+
1720
gosu --version;
1821
gosu nobody true

install-paper.sh

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
1-
#!/bin/sh
2-
# https://docs.papermc.io/misc/downloads-api
3-
set -eux
1+
#!/usr/bin/env sh
2+
set -e
43

5-
# get latest mc version if env var is not set
4+
# https://docs.papermc.io/misc/downloads-api
65
: "${MC_VERSION:=$(curl -s 'https://api.papermc.io/v2/projects/paper' | jq -r '.versions[-1]')}"
6+
: "${BUILD:=$(curl -s "https://api.papermc.io/v2/projects/paper/versions/${MC_VERSION}/builds" | jq -r '.builds | map(select(.channel == "default") | .build) | .[-1]')}"
77

8-
# get latest stable build for mc version
9-
LATEST_BUILD=$(curl -s "https://api.papermc.io/v2/projects/paper/versions/${MC_VERSION}/builds" | \
10-
jq -r '.builds | map(select(.channel == "default") | .build) | .[-1]')
11-
12-
if [ "$LATEST_BUILD" != "null" ]; then
13-
JAR_NAME="paper-${MC_VERSION}-${LATEST_BUILD}.jar"
14-
PAPERMC_URL="https://api.papermc.io/v2/projects/paper/versions/${MC_VERSION}/builds/${LATEST_BUILD}/downloads/${JAR_NAME}"
15-
curl -o /tmp/server.jar "$PAPERMC_URL"
8+
if [ "$BUILD" != "null" ]; then
9+
JAR_NAME="paper-${MC_VERSION}-${BUILD}.jar"
10+
PAPERMC_URL="https://api.papermc.io/v2/projects/paper/versions/${MC_VERSION}/builds/${BUILD}/downloads/${JAR_NAME}"
11+
echo "$PAPERMC_URL"
12+
curl -o /opt/minecraft/server.jar "$PAPERMC_URL"
1613
else
1714
echo "No stable build for version ${MC_VERSION} found!"
1815
exit 1
19-
fi
16+
fi

0 commit comments

Comments
 (0)