diff --git a/.github/workflows/build-multiarch.yml b/.github/workflows/build-multiarch.yml index de1eecde..3f37ce8c 100644 --- a/.github/workflows/build-multiarch.yml +++ b/.github/workflows/build-multiarch.yml @@ -6,7 +6,6 @@ on: - test/** tags: - "[0-9]+.[0-9]+.[0-9]+" - - "[0-9]+.[0-9]+.[0-9]+-*" paths-ignore: - "*.md" - "docs/**" @@ -39,7 +38,7 @@ jobs: - variant: java8-multiarch baseImage: eclipse-temurin:8-jdk tagPrefix: java8- - platforms: linux/amd64,linux/arm/v7,linux/arm64 + platforms: linux/amd64,linux/arm64 mcVersion: 1.12.2 - variant: java8-openj9 baseImage: ibm-semeru-runtimes:open-8-jdk @@ -71,7 +70,7 @@ jobs: itzg/minecraft-server tags: | type=ref,event=tag,enable=${{ matrix.variant == 'java17' }} - type=ref,event=tag,prefix=${{ matrix.variant }}- + type=ref,event=tag,suffix=-${{ matrix.variant }} type=raw,value=${{ matrix.variant }} flavor: | latest=${{ matrix.variant == 'java17' }} @@ -116,7 +115,7 @@ jobs: uses: docker/build-push-action@v2.8.0 with: platforms: ${{ matrix.platforms }} - push: ${{ github.ref_name == 'master' }} + push: ${{ github.ref_type == 'tag' || github.ref_name == 'master' }} tags: ${{ steps.meta.outputs.tags }} # ensure latest base image is used pull: true diff --git a/.github/workflows/discord.yml b/.github/workflows/discord.yml index 495b6e47..3b1619fe 100644 --- a/.github/workflows/discord.yml +++ b/.github/workflows/discord.yml @@ -1,4 +1,4 @@ -name: discord +name: Discord notifications on: workflow_run: diff --git a/.github/workflows/issue-label.yml b/.github/workflows/issue-label.yml index cc4f3b56..a628c898 100644 --- a/.github/workflows/issue-label.yml +++ b/.github/workflows/issue-label.yml @@ -1,3 +1,5 @@ +name: Issue labels + on: issues: types: [labeled] diff --git a/Dockerfile b/Dockerfile index 3d3e77e3..3e83e3d4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -62,7 +62,7 @@ RUN easy-add --var os=${TARGETOS} --var arch=${TARGETARCH}${TARGETVARIANT} \ --var version=0.1.1 --var app=maven-metadata-release --file {{.app}} \ --from https://github.com/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz -ARG MC_HELPER_VERSION=1.16.3 +ARG MC_HELPER_VERSION=1.16.5 ARG MC_HELPER_BASE_URL=https://github.com/itzg/mc-image-helper/releases/download/v${MC_HELPER_VERSION} RUN curl -fsSL ${MC_HELPER_BASE_URL}/mc-image-helper-${MC_HELPER_VERSION}.tgz \ | tar -C /usr/share -zxf - \ diff --git a/README.md b/README.md index fba72354..8d9fbe66 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ By default, the container will download the latest version of the "vanilla" [Min * [Optional plugins, mods, and config attach points](#optional-plugins-mods-and-config-attach-points) * [Auto-downloading SpigotMC/Bukkit/PaperMC plugins](#auto-downloading-spigotmcbukkitpapermc-plugins) * [Downloadable mod/plugin pack for Forge, Fabric, and Bukkit-like Servers](#downloadable-modplugin-pack-for-forge-fabric-and-bukkit-like-servers) - * [ForgeAPI usage to use non-version specific projects](#forgeapi-usage-to-use-non-version-specific-projects) + * [ForgeAPI usage to use non-version specific projects](#forgeapi-usage-to-use-non-version-specific-projects) * [Generic pack files](#generic-pack-files) * [Mod/Plugin URL Listing File](#modplugin-url-listing-file) * [Remove old mods/plugins](#remove-old-modsplugins) @@ -134,6 +134,7 @@ By default, the container will download the latest version of the "vanilla" [Min * [Stop Duration](#stop-duration) * [Setup only](#setup-only) * [Enable Flare Flags](#enable-flare-flags) + * [Enable timestamps in init logs](#enable-timestamps-in-init-logs) * [Autopause](#autopause) * [Description](#description) * [Enabling Autopause](#enabling-autopause) @@ -141,7 +142,7 @@ By default, the container will download the latest version of the "vanilla" [Min * [Running on RaspberryPi](#running-on-raspberrypi) * [Contributing](#contributing) - + @@ -746,9 +747,9 @@ You may also download or copy over individual mods using the `MODS` environment docker run -d -e MODS=https://www.example.com/mods/mod1.jar,/plugins/common,/plugins/special/mod2.jar ... -### **ForgeAPI** usage to use non-version specific projects +### ForgeAPI usage to use non-version specific projects -**NOTE:** This potentially could lead to unexpected behavior if the Mod recieves an update with unexpected behavior. +**NOTE:** This potentially could lead to unexpected behavior if the Mod receives an update with unexpected behavior. This is more complicated because you will be pulling/using the latest mod for the release of your game. To get started make sure you have a [CursedForge API Key](https://docs.curseforge.com/#getting-started). Then use the environmental parameters in your docker build. @@ -774,10 +775,10 @@ Example of expected forge api project ids, releases, and key: Example of expected ForgeAPI file format. **Field Description**: -* Name is currently unused, but can be used to document each entry. -* Project id is the id found on the CurseForge website for a particular mod -* Release Type corresponds to forge's R, B, A icon for each file. Default Release, options are (release|beta|alpha). -* FileName is used for version pinning if latest file will not work for you. +* `name` is currently unused, but can be used to document each entry. +* `projectId` id is the id found on the CurseForge website for a particular mod +* `releaseType` Type corresponds to forge's R, B, A icon for each file. Default Release, options are (release|beta|alpha). +* `fileName` is used for version pinning if latest file will not work for you. ```json [ @@ -802,7 +803,7 @@ Example of expected ForgeAPI file format. ### Generic pack files -To install all of the server content (jars, mods, plugins, configs, etc) from a zip or tgz file, such as a CurseForge modpack that is missing a server start script, then set `GENERIC_PACK` to the container path or URL of the archive file. +To install all the server content (jars, mods, plugins, configs, etc.) from a zip or tgz file, then set `GENERIC_PACK` to the container path or URL of the archive file. This can also be used to apply a CurseForge modpack that is missing a server start script and/or Forge installer. If multiple generic packs need to be applied together, set `GENERIC_PACKS` instead, with a comma separated list of archive file paths and/or URLs to files. @@ -816,6 +817,8 @@ GENERIC_PACKS_SUFFIX=.zip would expand to `https://cdn.example.org/configs-v9.0.1.zip,https://cdn.example.org/mods-v4.3.6.zip`. +If applying large generic packs, the update check can be time-consuming since a SHA1 checksum is compared. To skip the update check set `SKIP_GENERIC_PACK_UPDATE_CHECK` to "true". Conversely, the generic pack(s) can be forced to be applied without comparing the checksum by setting `FORCE_GENERIC_PACK_UPDATE` to "true". + ### Mod/Plugin URL Listing File As an alternative to `MODS`, the variable `MODS_FILE` can be set with the path to a text file listing a mod/plugin URL on each line. For example, the following @@ -1559,6 +1562,20 @@ To enable the JVM flags required to fully support the [Flare profiling suite](ht Flare is built-in to Airplane/Pufferfish/Purpur, and is available in [plugin form](https://github.com/TECHNOVE/FlarePlugin) for other server types. +### Enable timestamps in init logs + +Before the container starts the Minecraft Server its output is prefixed with `[init]`, such as + +``` +[init] Starting the Minecraft server... +``` + +To also include the timestamp with each log, set `LOG_TIMESTAMP` to "true". The log output will then look like: + +``` +[init] 2022-02-05 16:58:33+00:00 Starting the Minecraft server... +``` + ## Autopause ### Description diff --git a/scripts/start-setupModpack b/scripts/start-setupModpack index 88281d4a..cc421780 100755 --- a/scripts/start-setupModpack +++ b/scripts/start-setupModpack @@ -29,7 +29,7 @@ if [[ "${PACKWIZ_URL}" ]]; then if [[ -z "${latestPackwiz}" ]]; then log "WARNING: Could not retrieve Packwiz bootstrap installer release information" else - isDebugging && log "Latest packwiz ${latestPackWiz}" + isDebugging && log "Latest packwiz ${latestPackwiz}" latestPackwizVer=$(echo ${latestPackwiz} | jq --raw-output '.tag_name') latestPackwizUrl=$(echo ${latestPackwiz} | jq --raw-output '.assets[] | select(.name | match("packwiz-installer-bootstrap.jar")) | .url') : "${PACKWIZ_JAR:=packwiz-installer-bootstrap_${latestPackwizVer}.jar}" @@ -199,6 +199,7 @@ if [[ "${GENERIC_PACKS}" ]]; then pack="${GENERIC_PACKS_PREFIX}${packEntry}${GENERIC_PACKS_SUFFIX}" if isURL "${pack}"; then mkdir -p /data/packs + log "Downloading generic pack from $pack" if ! outfile=$(get -o /data/packs --output-filename --skip-existing "$pack"); then log "ERROR: failed to download $pack" exit 2 @@ -210,7 +211,13 @@ if [[ "${GENERIC_PACKS}" ]]; then done isDebugging && [ -f "$sum_file}" ] && cat "$sum_file" - if ! sha1sum -c "${sum_file}" --status 2> /dev/null; then + + log "Checking if generic packs are up to date" + if isTrue "${SKIP_GENERIC_PACK_UPDATE_CHECK:-false}" && [ -f "$sum_file" ]; then + log "Skipping generic pack update check" + elif isTrue "${FORCE_GENERIC_PACK_UPDATE}" || ! sha1sum -c "${sum_file}" --status 2> /dev/null; then + log "Generic pack(s) are out of date. Re-applying..." + base_dir=/tmp/generic_pack_base mkdir -p ${base_dir} for pack in "${packFiles[@]}"; do @@ -243,6 +250,7 @@ if [[ "${GENERIC_PACKS}" ]]; then cp -R -f "${base_dir}"/* /data rm -rf /tmp/generic_pack_base + log "Saving generic pack(s) checksum" sha1sum "${packFiles[@]}" > "${sum_file}" isDebugging && cat "$sum_file" fi diff --git a/scripts/start-utils b/scripts/start-utils index 0c7d3479..ccac4376 100755 --- a/scripts/start-utils +++ b/scripts/start-utils @@ -40,6 +40,10 @@ function getFilenameFromUrl() { } function isTrue() { + local oldState + oldState=$(shopt -po xtrace) + shopt -u -o xtrace + local value=${1,,} result= @@ -53,6 +57,7 @@ function isTrue() { ;; esac + eval "$oldState" return ${result} } @@ -82,7 +87,18 @@ function logn() { } function log() { - echo "[init] $*" + local oldState + # The return status when listing options is zero if all optnames are enabled, non- zero otherwise. + oldState=$(shopt -po xtrace || true) + shopt -u -o xtrace + + if isDebugging || isTrue "${LOG_TIMESTAMP:-false}"; then + ts=" $(date --rfc-3339=seconds)" + else + ts= + fi + echo "[init]${ts} $*" + eval "$oldState" } function logAutopause() { diff --git a/tests/setuponlytests/forgeapimods_file/docker-compose.yml b/tests/setuponlytests/forgeapimods_file/docker-compose.disabled.yml similarity index 100% rename from tests/setuponlytests/forgeapimods_file/docker-compose.yml rename to tests/setuponlytests/forgeapimods_file/docker-compose.disabled.yml diff --git a/tests/setuponlytests/forgeapimods_projectids/docker-compose.yml b/tests/setuponlytests/forgeapimods_projectids/docker-compose.disabled.yml similarity index 100% rename from tests/setuponlytests/forgeapimods_projectids/docker-compose.yml rename to tests/setuponlytests/forgeapimods_projectids/docker-compose.disabled.yml diff --git a/tests/setuponlytests/generic-packs/docker-compose.yml b/tests/setuponlytests/generic-packs/docker-compose.yml index b5450605..a2b27c5d 100644 --- a/tests/setuponlytests/generic-packs/docker-compose.yml +++ b/tests/setuponlytests/generic-packs/docker-compose.yml @@ -11,8 +11,14 @@ services: image: ${IMAGE_TO_TEST:-itzg/minecraft-server} environment: EULA: "true" - SETUP_ONLY: "TRUE" + SETUP_ONLY: "true" GENERIC_PACKS: http://web/configs.zip,/packs/testing.zip + LOG_TIMESTAMP: "true" + # the following are only used to speed up test execution + TYPE: CUSTOM + CUSTOM_SERVER: /servers/fake.jar + VERSION: 1.18.1 volumes: - ./packs:/packs - ./data:/data + - ./fake.jar:/servers/fake.jar diff --git a/tests/setuponlytests/generic-packs/fake.jar b/tests/setuponlytests/generic-packs/fake.jar new file mode 100644 index 00000000..e69de29b