From 38028f7d0c31b4e6691a4709fc489e3d127c44a9 Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Sat, 11 Jul 2020 13:17:28 -0500 Subject: [PATCH 01/11] Confirm latest Spigot jar is always downloaded --- start-deployBukkitSpigot | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/start-deployBukkitSpigot b/start-deployBukkitSpigot index 28b07fd3..cb2309e5 100644 --- a/start-deployBukkitSpigot +++ b/start-deployBukkitSpigot @@ -62,8 +62,12 @@ function downloadSpigot { downloadUrl="https://cdn.getbukkit.org/${getbukkitFlavor}/${getbukkitFlavor}-${VANILLA_VERSION}.jar" fi + if [ -f $SERVER ]; then + # tell curl to only download when newer + zarg="-z $SERVER" + fi log "Downloading $match from $downloadUrl ..." - curl -fsSL -o $SERVER "$downloadUrl" + curl -fsSL -o $SERVER $zarg "$downloadUrl" if [[ $? != 0 || $(grep -c "DOCTYPE html" $SERVER) != 0 ]]; then cat < Date: Sat, 11 Jul 2020 13:30:39 -0500 Subject: [PATCH 02/11] Confirm latest Paper jar is always downloaded --- start-deployPaper | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/start-deployPaper b/start-deployPaper index f3d12472..1bc5839e 100644 --- a/start-deployPaper +++ b/start-deployPaper @@ -5,17 +5,18 @@ : ${PAPERBUILD:=latest} export SERVER=paper_server-${VANILLA_VERSION}-${PAPERBUILD}.jar -if [ ! -f "$SERVER" ] || [ -n "$FORCE_REDOWNLOAD" ]; then - downloadUrl=${PAPER_DOWNLOAD_URL:-https://papermc.io/api/v1/paper/${VANILLA_VERSION}/${PAPERBUILD}/download} - log "Downloading Paper $VANILLA_VERSION (build $PAPERBUILD) from $downloadUrl ..." - curl -fsSL -o "$SERVER" "$downloadUrl" - if [ ! -f "$SERVER" ]; then - log "ERROR: failed to download from $downloadUrl (status=$?)" - exit 3 - fi +if [ -f "$SERVER" ] && ! isTrue "$FORCE_REDOWNLOAD"; then + zarg="-z '$SERVER'" fi -# Normalize on Spigot for operations below +downloadUrl=${PAPER_DOWNLOAD_URL:-https://papermc.io/api/v1/paper/${VANILLA_VERSION}/${PAPERBUILD}/download} +log "Downloading Paper $VANILLA_VERSION (build $PAPERBUILD) from $downloadUrl ..." +if ! curl -fsSL -o "$SERVER" $zarg "$downloadUrl"; then + log "ERROR: failed to download from $downloadUrl (status=$?)" + exit 3 +fi + +# Normalize on Spigot for downstream operations export TYPE=SPIGOT export SKIP_LOG4J_CONFIG=true From 367c6cfd92db74f26fc8ee7e410f7a68a9cdf1f1 Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Sat, 11 Jul 2020 14:09:08 -0500 Subject: [PATCH 03/11] ci: Added testing step to github actions --- .github/workflows/main.yml | 11 +++++++++++ .github/workflows/pr.yml | 11 ++++------- tests/docker-compose.test.yml | 16 ++++++++++++++++ tests/test.sh | 13 +++++++++++++ 4 files changed, 44 insertions(+), 7 deletions(-) create mode 100644 tests/docker-compose.test.yml create mode 100755 tests/test.sh diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 388a5fea..f3673005 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,7 +16,18 @@ on: - "[0-9]+.[0-9]+.[0-9]+-adopt13" jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Run tests + run: | + tests/test.sh build: + needs: + - test runs-on: ubuntu-latest steps: diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 94d19913..16096da7 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -5,15 +5,12 @@ on: branches: [ master ] jobs: - build: + test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Build Docker image - uses: docker/build-push-action@v1.1.0 - with: - tag_with_sha: true - cache_froms: itzg/minecraft-server:latest - push: false + - name: Run tests + run: | + tests/test.sh diff --git a/tests/docker-compose.test.yml b/tests/docker-compose.test.yml new file mode 100644 index 00000000..49271b76 --- /dev/null +++ b/tests/docker-compose.test.yml @@ -0,0 +1,16 @@ +version: "3.8" + +services: + sut: + depends_on: + - mc + image: itzg/mc-monitor:0.6.0 + command: status --host mc --retry-interval 1s --retry-limit 120 + mc: + build: + context: .. + cache_from: + - itzg/minecraft-server:latest + environment: + EULA: "TRUE" + diff --git a/tests/test.sh b/tests/test.sh new file mode 100755 index 00000000..2f11b894 --- /dev/null +++ b/tests/test.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +cd $(dirname $0) + +failed=false +args="-f docker-compose.test.yml" +docker-compose $args run sut || failed=true; docker-compose $args logs mc +docker-compose $args down -v + +if $failed; then + exit 1 +fi + From 3c9df035848f34b6c980c6f156dc71187a521562 Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Sat, 11 Jul 2020 14:13:28 -0500 Subject: [PATCH 04/11] ci: Only output server logs when failed --- tests/test.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test.sh b/tests/test.sh index 2f11b894..7da85273 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -4,7 +4,8 @@ cd $(dirname $0) failed=false args="-f docker-compose.test.yml" -docker-compose $args run sut || failed=true; docker-compose $args logs mc +docker-compose $args run sut || failed=true +$failed && docker-compose $args logs mc docker-compose $args down -v if $failed; then From 90183ae8236530b7c9cd6ef65bdeaa9cf532188b Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Sat, 11 Jul 2020 14:26:47 -0500 Subject: [PATCH 05/11] ci: Don't restart failed container during test --- tests/docker-compose.test.yml | 1 + tests/test.sh | 3 +++ 2 files changed, 4 insertions(+) diff --git a/tests/docker-compose.test.yml b/tests/docker-compose.test.yml index 49271b76..ed96ba50 100644 --- a/tests/docker-compose.test.yml +++ b/tests/docker-compose.test.yml @@ -7,6 +7,7 @@ services: image: itzg/mc-monitor:0.6.0 command: status --host mc --retry-interval 1s --retry-limit 120 mc: + restart: "no" build: context: .. cache_from: diff --git a/tests/test.sh b/tests/test.sh index 7da85273..376aed99 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -5,6 +5,9 @@ cd $(dirname $0) failed=false args="-f docker-compose.test.yml" docker-compose $args run sut || failed=true +echo " +Result: failed=$failed" + $failed && docker-compose $args logs mc docker-compose $args down -v From 4fef391b646e80d810c53566a5ac435726017a31 Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Sun, 12 Jul 2020 11:36:31 -0500 Subject: [PATCH 06/11] misc: Switched maintainer label to opencontainers schema --- .github/workflows/main.yml | 1 + Dockerfile | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f3673005..9e436904 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -43,4 +43,5 @@ jobs: tag_with_sha: false cache_froms: itzg/minecraft-server:latest add_git_labels: true + labels: org.opencontainers.image.url=https://github.com/itzg/docker-minecraft-server,org.opencontainers.image.documentation=https://github.com/itzg/docker-minecraft-server push: true diff --git a/Dockerfile b/Dockerfile index eddce74a..e7a5ae0a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM openjdk:8u212-jre-alpine -LABEL maintainer "itzg" +LABEL org.opencontainers.image.authors="Geoff Bourne " RUN apk add --no-cache -U \ openssl \ From 796f2fe14a72fc6914ab0a1ae756c9def6a5e13a Mon Sep 17 00:00:00 2001 From: Code Monad Date: Tue, 14 Jul 2020 10:00:46 +0800 Subject: [PATCH 07/11] Add support for rcon password from file (#585) --- start-configuration | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/start-configuration b/start-configuration index 1218ca7f..26712e4f 100644 --- a/start-configuration +++ b/start-configuration @@ -45,6 +45,22 @@ if [[ $PROXY ]]; then sleep 5 fi +if [[ $RCON_PASSWORD_FILE ]]; then + log "" + if [ ! -e ${RCON_PASSWORD_FILE} ]; then + log "Initial RCON password file ${RCON_PASSWORD_FILE} does not seems to exist." + log "Please ensure your configuration." + log "If you are using Docker Secrets feature, please check this for further information: " + log " https://docs.docker.com/engine/swarm/secrets" + log "" + exit 1 + else + RCON_PASSWORD=$(cat ${RCON_PASSWORD_FILE}) + export RCON_PASSWORD + fi + log "" +fi + export SERVER_PROPERTIES=/data/server.properties export VERSIONS_JSON=https://launchermeta.mojang.com/mc/game/version_manifest.json From 3b2b98b9fe72d46e5a264a139f5de254baca1ee8 Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Tue, 14 Jul 2020 21:07:57 -0500 Subject: [PATCH 08/11] Upgrade base image packages For #586 --- Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Dockerfile b/Dockerfile index e7a5ae0a..bfbd9a2a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,6 +2,9 @@ FROM openjdk:8u212-jre-alpine LABEL org.opencontainers.image.authors="Geoff Bourne " +# upgrade all packages since alpine jre8 base image tops out at 8u212 +RUN apk -U --no-cache upgrade + RUN apk add --no-cache -U \ openssl \ imagemagick \ From 6fe13e8654ffb3ce875f0b0c129785317bd49b32 Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Sat, 18 Jul 2020 13:09:58 -0500 Subject: [PATCH 09/11] Clarified "invalid type" message for FTBA on multiarch --- start-configuration | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/start-configuration b/start-configuration index 26712e4f..deb6e792 100644 --- a/start-configuration +++ b/start-configuration @@ -145,8 +145,9 @@ case "${TYPE^^}" in *) log "Invalid type: '$TYPE'" - log "Must be: VANILLA, FORGE, BUKKIT, SPIGOT, PAPER, FTBA, CURSEFORGE, SPONGEVANILLA," - log " CUSTOM, CURSE_INSTANCE, MAGMA, MOHIST, CATSERVER" + log "Must be: VANILLA, FORGE, BUKKIT, SPIGOT, PAPER, FTBA (multiarch-only)," + log " CURSE_INSTANCE, CURSEFORGE, SPONGEVANILLA," + log " CUSTOM, MAGMA, MOHIST, CATSERVER" exit 1 ;; From 692087dd25b85f433c8f5348bca9dcb44d4bcf5b Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Sat, 18 Jul 2020 13:49:40 -0500 Subject: [PATCH 10/11] Ensured ops.txt and white-list.txt are always provided for CURSEFORGE/FTB type (#584) --- start-minecraftFinalSetup | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/start-minecraftFinalSetup b/start-minecraftFinalSetup index 1d20da55..5b8af846 100644 --- a/start-minecraftFinalSetup +++ b/start-minecraftFinalSetup @@ -170,13 +170,10 @@ if [[ ${TYPE} == "CURSE_INSTANCE" ]]; then elif [[ ${TYPE} == "FEED-THE-BEAST" ]]; then mcServerRunnerArgs="${mcServerRunnerArgs} --shell bash" - if [ ! -e "${FTB_DIR}/ops.json" -a -e /data/ops.txt ]; then - cp -f /data/ops.txt ${FTB_DIR}/ - fi - - if [ ! -e "${FTB_DIR}/whitelist.json" -a -e /data/white-list.txt ]; then - cp -f /data/white-list.txt ${FTB_DIR}/ - fi + # copy player modification files unconditionally since their + # processing into json is additive anyway + [ -f /data/ops.txt ] && cp -f /data/ops.txt ${FTB_DIR}/ + [ -f /data/white-list.txt ] && cp -f /data/white-list.txt ${FTB_DIR}/ if [ ! -e "${FTB_DIR}/server-icon.png" -a -e /data/server-icon.png ]; then cp -f /data/server-icon.png ${FTB_DIR}/ From 747c1888240a6dfd1a0fea8e26a2327f08b462f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20Z=C3=BChlcke?= Date: Sun, 19 Jul 2020 01:31:29 +0200 Subject: [PATCH 11/11] Use -prune for "REPLACE_ENV_VARIABLES_EXCLUDE_PATHS" feature. (#588) --- README.md | 8 +++++++- start-finalSetupEnvVariables | 15 ++++++++++----- start-utils | 2 ++ 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 7b83c20d..0d5e7bcb 100644 --- a/README.md +++ b/README.md @@ -324,7 +324,13 @@ There are some limitations to what characters you can use. Variables will be replaced in files with the following extensions: `.yml`, `.yaml`, `.txt`, `.cfg`, `.conf`, `.properties`. -Specific files can be excluded by listing their name (without path) in the variable `REPLACE_ENV_VARIABLES_EXCLUDES`. Paths can be excluded by listing them in the variable `REPLACE_ENV_VARIABLES_EXCLUDE_PATHS`. +Specific files can be excluded by listing their name (without path) in the variable `REPLACE_ENV_VARIABLES_EXCLUDES`. + +Paths can be excluded by listing them in the variable `REPLACE_ENV_VARIABLES_EXCLUDE_PATHS`. Path +excludes are recursive. Here is an example: +``` +REPLACE_ENV_VARIABLES_EXCLUDE_PATHS="/data/plugins/Essentials/userdata/ /data/plugins/MyPlugin/" +``` Here is a full example where we want to replace values inside a `database.yml`. diff --git a/start-finalSetupEnvVariables b/start-finalSetupEnvVariables index f64f5ec7..4dfc04ca 100644 --- a/start-finalSetupEnvVariables +++ b/start-finalSetupEnvVariables @@ -6,15 +6,20 @@ if isTrue "${REPLACE_ENV_VARIABLES}"; then log "Replacing env variables in configs that match the prefix $ENV_VARIABLE_PREFIX..." - findExcludes= + + # File excludes for f in ${REPLACE_ENV_VARIABLES_EXCLUDES}; do findExcludes="${findExcludes} -not -name $f" done - for p in ${REPLACE_ENV_VARIABLES_EXCLUDE_PATHS}; do - findExcludes="${findExcludes} -not -path \"*$p*\"" - done - isDebugging && echo "Using find exclusion: $findExcludes" + + # Directory excludes (recursive) + dirExcludes=$(join_by " -o -path " ${REPLACE_ENV_VARIABLES_EXCLUDE_PATHS}) + if [[ $dirExcludes ]]; then + findExcludes+=" -type d ( -path ${dirExcludes} ) -prune" + fi + + isDebugging && echo "Using find exclusions: $findExcludes" while IFS='=' read -r name value ; do # check if name of env variable matches the prefix diff --git a/start-utils b/start-utils index aa8d933a..0c6fd763 100644 --- a/start-utils +++ b/start-utils @@ -1,5 +1,7 @@ #!/bin/bash +function join_by { local d=$1; shift; echo -n "$1"; shift; printf "%s" "${@/#/$d}"; } + function isURL { local value=$1