Skip to content

Commit 734a0c9

Browse files
authored
fix: migrate from Bash to POSIX-compliant sh (#85)
Reduce both image size and surface area.
1 parent 8900395 commit 734a0c9

File tree

2 files changed

+22
-21
lines changed

2 files changed

+22
-21
lines changed

src/main/docker/Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,9 @@ COPY --from=jre-build /jre ${JAVA_HOME}
6262
ENV EULA=false
6363

6464
# Keep dependencies up-to-date
65-
# bash is still required by start.sh for now (to be removed)
6665
# gettext is required for envsubst: https://pkgs.alpinelinux.org/package/edge/main/x86_64/gettext
6766
# libudev-zero is the Alpine-equivalent of libudev, which is required by PaperMC: https://pkgs.alpinelinux.org/package/edge/community/x86/libudev-zero
68-
RUN apk add --no-cache bash gettext libudev-zero
67+
RUN apk add --no-cache gettext libudev-zero
6968

7069
# Create the "papermc" user
7170
#

src/main/docker/runtime/start.sh

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
#!/usr/bin/env bash
2-
# TODO: migrate to sh
1+
#!/usr/bin/env sh
32

4-
set -Eeuo pipefail
3+
set -eu
54

6-
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
5+
SCRIPT_DIR=$(cd "$(dirname "$0")" > /dev/null 2>&1 && pwd -P)
76

87
## Directories
98
CONFIG_DIR="${SCRIPT_DIR}/config"
@@ -16,10 +15,9 @@ WORLD_DIR="${SCRIPT_DIR}/worlds"
1615
# Paper config: https://docs.papermc.io/paper/reference/global-configuration
1716
# Aïkar's flags: https://docs.papermc.io/paper/aikars-flags
1817
# Paper system properties: https://docs.papermc.io/paper/reference/system-properties
19-
HEAP_SIZE=4
20-
AIKAR_FLAGS=(
21-
-Xms"${HEAP_SIZE}"G
22-
-Xmx"${HEAP_SIZE}"G
18+
AIKAR_FLAGS="
19+
-Xms4G
20+
-Xmx4G
2321
-XX:+AlwaysPreTouch
2422
-XX:+DisableExplicitGC
2523
-XX:+ParallelRefProcEnabled
@@ -40,32 +38,36 @@ AIKAR_FLAGS=(
4038
-XX:SurvivorRatio=32
4139
-Dusing.aikars.flags=https://mcflags.emc.gs
4240
-Daikars.new.flags=true
43-
)
44-
PAPER_FLAGS=(
41+
"
42+
PAPER_FLAGS='
4543
-Dnet.kyori.adventure.text.warnWhenLegacyFormattingDetected
4644
-Dpaper.ticklist-warn-on-excessive-delay
4745
-Dpaper.strict-thread-checks
4846
-DPaper.skipServerPropertiesComments
4947
-Dpaper.alwaysPrintWarningState
50-
)
51-
JVM_ARGUMENTS=("${AIKAR_FLAGS[@]}" "${SPIGOT_FLAGS[@]}" "${PAPER_FLAGS[@]}")
48+
'
49+
50+
# Combine all JVM arguments into a single string
51+
JVM_ARGUMENTS="${AIKAR_FLAGS} ${PAPER_FLAGS}"
5252

5353
## Server arguments
5454
# Spigot start-up parameters: https://www.spigotmc.org/wiki/start-up-parameters/
55-
SERVER_ARGS=(
56-
--spigot-settings "${CONFIG_DIR}/spigot.yml"
57-
--commands-settings "${CONFIG_DIR}/commands.yml"
58-
--world-dir "${WORLD_DIR}"
55+
SERVER_ARGS="
56+
--spigot-settings ${CONFIG_DIR}/spigot.yml
57+
--commands-settings ${CONFIG_DIR}/commands.yml
58+
--world-dir ${WORLD_DIR}
5959
--log-strip-color
6060
--nogui
61-
)
61+
"
6262

6363
cd "${SCRIPT_DIR}"
6464

6565
echo 'Preparing PaperMC server configuration files...'
6666

67-
TMP="$(envsubst '$EULA' < eula.txt)" && echo "${TMP}" > eula.txt && echo 'File eula.txt processed'
67+
TMP="$(envsubst '$EULA' < eula.txt)"
68+
echo "${TMP}" > eula.txt
69+
echo 'File eula.txt processed'
6870

6971
echo 'PaperMC server ready to start!'
7072

71-
java "${JVM_ARGUMENTS[@]}" -jar "${SCRIPT_DIR}"/papermc-server-*.jar "${SERVER_ARGS[@]}"
73+
java $JVM_ARGUMENTS -jar "${SCRIPT_DIR}"/papermc-server-*.jar $SERVER_ARGS

0 commit comments

Comments
 (0)