diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 1c44c923672..886c2317773 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,5 +1,4 @@ - -#github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +github: itzg custom: - https://www.buymeacoffee.com/itzg - https://paypal.me/itzg diff --git a/.github/workflows/build-multiarch.yml b/.github/workflows/build-multiarch.yml index d99119084f1..6cbb59fe2b0 100644 --- a/.github/workflows/build-multiarch.yml +++ b/.github/workflows/build-multiarch.yml @@ -1,4 +1,4 @@ -name: Build and publish multiarch +name: Test and Build multi-architecture on: push: branches: @@ -10,6 +10,13 @@ on: - "*.md" - "docs/**" - "examples/**" + pull_request: + branches: [ master ] + types: [assigned, opened, synchronize, labeled] + paths-ignore: + - "*.md" + - "docs/**" + - "examples/**" jobs: build: @@ -120,12 +127,6 @@ jobs: - name: Set up QEMU uses: docker/setup-qemu-action@v2.0.0 - - name: Login to DockerHub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKER_USER }} - password: ${{ secrets.DOCKER_PASSWORD }} - - name: Build for test uses: docker/build-push-action@v3.0.0 with: @@ -149,12 +150,23 @@ jobs: run: | tests/test.sh + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USER }} + password: ${{ secrets.DOCKER_PASSWORD }} + - name: Build and push id: docker_build uses: docker/build-push-action@v3.0.0 with: platforms: ${{ matrix.platforms }} - push: ${{ github.ref_type == 'tag' || github.ref_name == 'master' }} + push: > + ${{ + github.ref_type == 'tag' + || github.ref_name == 'master' + || ( github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'ci/push-image') ) + }} tags: ${{ steps.meta.outputs.tags }} # ensure latest base image is used pull: true diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml deleted file mode 100644 index d940a3d58ac..00000000000 --- a/.github/workflows/pr.yml +++ /dev/null @@ -1,73 +0,0 @@ -name: PullRequest - -on: - pull_request: - branches: [ master ] - types: [assigned, opened, synchronize, labeled] - paths-ignore: - - "*.md" - - "docs/**" - - "examples/**" - -env: - IMAGE_TO_TEST: itzg/minecraft-server:test-${{ github.repository_owner }}-${{ github.run_id }} - -jobs: - test: - runs-on: ubuntu-20.04 - - steps: - - uses: actions/checkout@v3 - - - name: Setup Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Build - uses: docker/build-push-action@v3.0.0 - with: - context: . - platforms: linux/amd64 - tags: ${{ env.IMAGE_TO_TEST }} - load: true - cache-from: type=gha - - - name: Run tests - env: - MODS_FORGEAPI_KEY: ${{ secrets.MODS_FORGEAPI_KEY }} - MINECRAFT_VERSION: 1.18.2 - run: | - tests/test.sh - push: - runs-on: ubuntu-20.04 - needs: - - test - if: contains(github.event.pull_request.labels.*.name, 'ci/push-image') - steps: - - uses: actions/checkout@v3 - - - name: Setup Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Gather Docker metadata - id: meta - uses: docker/metadata-action@v4 - with: - images: | - itzg/minecraft-server - - - name: Login to DockerHub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKER_USER }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Push - uses: docker/build-push-action@v3.0.0 - with: - context: . - platforms: linux/amd64 - tags: ${{ steps.meta.outputs.tags }} - pull: true - push: true - cache-from: type=gha - labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile index b90495c6bcf..0b02b3dd00b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -46,7 +46,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.19.0 +ARG MC_HELPER_VERSION=1.20.1 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 - \ @@ -72,4 +72,4 @@ COPY --chmod=755 files/rconcmds /rconcmds RUN dos2unix /start* /autopause/* /autostop/* /rconcmds/* ENTRYPOINT [ "/start" ] -HEALTHCHECK --start-period=1m CMD mc-health +HEALTHCHECK --start-period=1m --interval=5s --retries=24 CMD mc-health diff --git a/README.md b/README.md index 21a4532cdce..6e312de8d79 100644 --- a/README.md +++ b/README.md @@ -235,9 +235,7 @@ An image that dockerizes [rcon-web-admin](https://github.com/rcon-web-admin/rcon ## Healthcheck -This image contains [mc-monitor](https://github.com/itzg/mc-monitor) and uses -its `status` command to continually check on the container's. That can be observed -from the `STATUS` column of `docker ps` +This image contains [mc-monitor](https://github.com/itzg/mc-monitor) and uses its `status` command to continually check on the container's. That can be observed from the `STATUS` column of `docker ps` ``` CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES @@ -251,6 +249,16 @@ You can also query the container's health in a script friendly way: healthy ``` +There's actually a wrapper script called `mc-health` that takes care of calling `mc-monitor status` with the correct arguments. If needing to customize the health checks parameters, such as in a compose file, then use something like the following in the service declaration: + +```yaml +healthcheck: + test: mc-health + start_period: 1m + interval: 5s + retries: 20 +``` + Some orchestration systems, such as Portainer, don't allow for disabling the default `HEALTHCHECK` declared by this image. In those cases you can approximate the disabling of healthchecks by setting the environment variable `DISABLE_HEALTHCHECK` to `true`. ## Deployment Templates and Examples diff --git a/scripts/start-deployPaper b/scripts/start-deployPaper index a0f83901a3d..79855ed8e1d 100755 --- a/scripts/start-deployPaper +++ b/scripts/start-deployPaper @@ -1,8 +1,11 @@ #!/bin/bash -. ${SCRIPTS:-/}start-utils +# shellcheck source=start-utils +. "${SCRIPTS:-/}start-utils" set -o pipefail -isDebugging && set -x +handleDebugMode + +: "${PAPER_CUSTOM_JAR:=}" ourScript="$0" ourArgs=("$@") @@ -28,7 +31,9 @@ function handleMissingVersion() { exit 1 } -if [[ $PAPER_DOWNLOAD_URL ]]; then +if [[ $PAPER_CUSTOM_JAR ]]; then + export SERVER="$PAPER_CUSTOM_JAR" +elif [[ $PAPER_DOWNLOAD_URL ]]; then export SERVER=$(getFilenameFromUrl "${PAPER_DOWNLOAD_URL}") if [ -f "$SERVER" ]; then diff --git a/scripts/start-setupModpack b/scripts/start-setupModpack index 34459fc8c4e..857aacc43ae 100755 --- a/scripts/start-setupModpack +++ b/scripts/start-setupModpack @@ -235,10 +235,12 @@ function genericPacks() { done # recalculate the actual base directory of content - base_dir=$(find "$base_dir" -maxdepth 3 -type d \( -name mods -o -name plugins -o -name config \) -printf '%h\n' | awk '{ print length;print $0 }' | sort -n -s | cut -d" " -f2- | head -n1 | xargs echo -n) - if [[ ! $base_dir ]]; then + if ! base_dir=$(mc-image-helper find \ + --max-depth=3 --type=directory --name=mods,plugins,config \ + --only-shallowest --fail-no-matches --format '%h' \ + "$base_dir"); then log "ERROR: Unable to find content base of generic packs ${GENERIC_PACKS}. Directories:" - find $original_base_dir -maxdepth 3 -type d -printf ' - %P\n' + mc-image-helper find --name=* --max-depth=3 --type=directory --format '- %P' "$original_base_dir" exit 1 fi diff --git a/tests/setuponlytests/conflicting_world_for_vanilla_server/docker-compose.yml b/tests/setuponlytests/conflicting_world_for_vanilla_server/docker-compose.yml index 4a30460e614..cd8136d525d 100644 --- a/tests/setuponlytests/conflicting_world_for_vanilla_server/docker-compose.yml +++ b/tests/setuponlytests/conflicting_world_for_vanilla_server/docker-compose.yml @@ -7,8 +7,13 @@ services: environment: EULA: "TRUE" SETUP_ONLY: "TRUE" - VERSION: ${MINECRAFT_VERSION:-LATEST} WORLD: /worlds/world-for-testing.zip + # the following are only used to speed up test execution + TYPE: CUSTOM + CUSTOM_SERVER: /servers/fake.jar + VERSION: 1.18.1 volumes: - ./worlds:/worlds:ro - ./data:/data + # the following are only used to speed up test execution + - ./verify.sh:/servers/fake.jar diff --git a/tests/setuponlytests/forgeapimods_file/docker-compose.yml b/tests/setuponlytests/forgeapimods_file/docker-compose.yml index 58c313ae572..d79222fed02 100644 --- a/tests/setuponlytests/forgeapimods_file/docker-compose.yml +++ b/tests/setuponlytests/forgeapimods_file/docker-compose.yml @@ -15,7 +15,7 @@ services: CUSTOM_SERVER: /servers/fake.jar VERSION: 1.18.2 MODS_FORGEAPI_FILE: /config/forgeapi_mods.json - # Key is defined in .github/workflows/pr.yml and ci.yml + # Key is passed by Github Workflow # This should be coming from github secrets. MODS_FORGEAPI_KEY: ${MODS_FORGEAPI_KEY} REMOVE_OLD_FORGEAPI_MODS: "TRUE" diff --git a/tests/setuponlytests/generic-packs-prefix/docker-compose.yml b/tests/setuponlytests/generic-packs-prefix/docker-compose.yml index 5519c89fb4c..f4c8e576576 100644 --- a/tests/setuponlytests/generic-packs-prefix/docker-compose.yml +++ b/tests/setuponlytests/generic-packs-prefix/docker-compose.yml @@ -10,6 +10,12 @@ services: GENERIC_PACKS_PREFIX: /packs/ GENERIC_PACKS_SUFFIX: .zip DEBUG: "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 + # the following are only used to speed up test execution + - ./verify.sh:/servers/fake.jar diff --git a/tests/setuponlytests/ops_from_scratch/docker-compose.yml b/tests/setuponlytests/ops_from_scratch/docker-compose.yml index 4cc8eb64b8d..0e6a7745a4d 100644 --- a/tests/setuponlytests/ops_from_scratch/docker-compose.yml +++ b/tests/setuponlytests/ops_from_scratch/docker-compose.yml @@ -7,7 +7,12 @@ services: environment: EULA: "TRUE" SETUP_ONLY: "TRUE" - VERSION: ${MINECRAFT_VERSION:-LATEST} OPS: itzg + # the following are only used to speed up test execution + TYPE: CUSTOM + CUSTOM_SERVER: /servers/fake.jar + VERSION: 1.18.1 volumes: - ./data:/data + # the following are only used to speed up test execution + - ./verify.sh:/servers/fake.jar diff --git a/tests/setuponlytests/spiget/docker-compose.yml b/tests/setuponlytests/spiget/docker-compose.yml index a114887153a..f5e6cd764ad 100644 --- a/tests/setuponlytests/spiget/docker-compose.yml +++ b/tests/setuponlytests/spiget/docker-compose.yml @@ -8,6 +8,8 @@ services: EULA: "TRUE" SETUP_ONLY: "TRUE" TYPE: PAPER + # jar doesn't need to exist for setuponly tests + PAPER_CUSTOM_JAR: /servers/fake.jar SPIGET_RESOURCES: "34315,3836,6245,2124" volumes: - ./data:/data diff --git a/tests/setuponlytests/spigot_world_for_spigot_server/docker-compose.yml b/tests/setuponlytests/spigot_world_for_spigot_server/docker-compose.yml index b8172d991ab..d30f146e967 100644 --- a/tests/setuponlytests/spigot_world_for_spigot_server/docker-compose.yml +++ b/tests/setuponlytests/spigot_world_for_spigot_server/docker-compose.yml @@ -7,9 +7,11 @@ services: environment: EULA: "TRUE" SETUP_ONLY: "TRUE" - VERSION: ${MINECRAFT_VERSION:-LATEST} TYPE: "PAPER" WORLD: /worlds/world-for-testing.zip + # the following are only used to speed up test execution + VERSION: 1.18.1 + PAPER_CUSTOM_JAR: /servers/fake.jar volumes: - ./worlds:/worlds:ro - ./data:/data diff --git a/tests/setuponlytests/spigot_world_for_vanilla_server/docker-compose.yml b/tests/setuponlytests/spigot_world_for_vanilla_server/docker-compose.yml index 4a30460e614..cd8136d525d 100644 --- a/tests/setuponlytests/spigot_world_for_vanilla_server/docker-compose.yml +++ b/tests/setuponlytests/spigot_world_for_vanilla_server/docker-compose.yml @@ -7,8 +7,13 @@ services: environment: EULA: "TRUE" SETUP_ONLY: "TRUE" - VERSION: ${MINECRAFT_VERSION:-LATEST} WORLD: /worlds/world-for-testing.zip + # the following are only used to speed up test execution + TYPE: CUSTOM + CUSTOM_SERVER: /servers/fake.jar + VERSION: 1.18.1 volumes: - ./worlds:/worlds:ro - ./data:/data + # the following are only used to speed up test execution + - ./verify.sh:/servers/fake.jar diff --git a/tests/setuponlytests/vanilla_world_for_spigot_server/docker-compose.yml b/tests/setuponlytests/vanilla_world_for_spigot_server/docker-compose.yml index b8172d991ab..d30f146e967 100644 --- a/tests/setuponlytests/vanilla_world_for_spigot_server/docker-compose.yml +++ b/tests/setuponlytests/vanilla_world_for_spigot_server/docker-compose.yml @@ -7,9 +7,11 @@ services: environment: EULA: "TRUE" SETUP_ONLY: "TRUE" - VERSION: ${MINECRAFT_VERSION:-LATEST} TYPE: "PAPER" WORLD: /worlds/world-for-testing.zip + # the following are only used to speed up test execution + VERSION: 1.18.1 + PAPER_CUSTOM_JAR: /servers/fake.jar volumes: - ./worlds:/worlds:ro - ./data:/data diff --git a/tests/setuponlytests/vanilla_world_for_vanilla_server/docker-compose.yml b/tests/setuponlytests/vanilla_world_for_vanilla_server/docker-compose.yml index 4a30460e614..cd8136d525d 100644 --- a/tests/setuponlytests/vanilla_world_for_vanilla_server/docker-compose.yml +++ b/tests/setuponlytests/vanilla_world_for_vanilla_server/docker-compose.yml @@ -7,8 +7,13 @@ services: environment: EULA: "TRUE" SETUP_ONLY: "TRUE" - VERSION: ${MINECRAFT_VERSION:-LATEST} WORLD: /worlds/world-for-testing.zip + # the following are only used to speed up test execution + TYPE: CUSTOM + CUSTOM_SERVER: /servers/fake.jar + VERSION: 1.18.1 volumes: - ./worlds:/worlds:ro - ./data:/data + # the following are only used to speed up test execution + - ./verify.sh:/servers/fake.jar diff --git a/tests/setuponlytests/vanillatweaks_file/docker-compose.yml b/tests/setuponlytests/vanillatweaks_file/docker-compose.yml index a2d31f01f94..50121820fe6 100644 --- a/tests/setuponlytests/vanillatweaks_file/docker-compose.yml +++ b/tests/setuponlytests/vanillatweaks_file/docker-compose.yml @@ -5,14 +5,17 @@ services: restart: "no" image: ${IMAGE_TO_TEST:-itzg/minecraft-server} environment: + VANILLATWEAKS_FILE: /config/vt-datapacks.json,/config/vt-craftingtweaks.json,/config/vt-resourcepacks.json EULA: "TRUE" SETUP_ONLY: "TRUE" + # the following are only used to speed up test execution + TYPE: CUSTOM CUSTOM_SERVER: /servers/fake.jar - VANILLATWEAKS_FILE: /config/vt-datapacks.json,/config/vt-craftingtweaks.json,/config/vt-resourcepacks.json - REMOVE_OLD_VANILLATWEAKS: "FALSE" + VERSION: 1.18.1 volumes: - ./data:/data - ./vt-datapacks.json:/config/vt-datapacks.json:ro - ./vt-craftingtweaks.json:/config/vt-craftingtweaks.json:ro - ./vt-resourcepacks.json:/config/vt-resourcepacks.json:ro - - ./fake.jar:/servers/fake.jar + # the following are only used to speed up test execution + - ./verify.sh:/servers/fake.jar diff --git a/tests/setuponlytests/vanillatweaks_file/fake.jar b/tests/setuponlytests/vanillatweaks_file/fake.jar deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/setuponlytests/vanillatweaks_sharecode/docker-compose.yml b/tests/setuponlytests/vanillatweaks_sharecode/docker-compose.yml index 35c8bd34a5f..fd6999a8489 100644 --- a/tests/setuponlytests/vanillatweaks_sharecode/docker-compose.yml +++ b/tests/setuponlytests/vanillatweaks_sharecode/docker-compose.yml @@ -5,10 +5,14 @@ services: restart: "no" image: ${IMAGE_TO_TEST:-itzg/minecraft-server} environment: + VANILLATWEAKS_SHARECODE: MGr52E,tF1zL2,LnEDwT EULA: "TRUE" SETUP_ONLY: "TRUE" + # the following are only used to speed up test execution + TYPE: CUSTOM CUSTOM_SERVER: /servers/fake.jar - VANILLATWEAKS_SHARECODE: MGr52E,tF1zL2,LnEDwT + VERSION: 1.18.1 volumes: - ./data:/data - - ./fake.jar:/servers/fake.jar + # the following are only used to speed up test execution + - ./verify.sh:/servers/fake.jar diff --git a/tests/setuponlytests/vanillatweaks_sharecode/fake.jar b/tests/setuponlytests/vanillatweaks_sharecode/fake.jar deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/setuponlytests/whitelist_from_scratch/docker-compose.yml b/tests/setuponlytests/whitelist_from_scratch/docker-compose.yml index a09104acd80..1e87c77438d 100644 --- a/tests/setuponlytests/whitelist_from_scratch/docker-compose.yml +++ b/tests/setuponlytests/whitelist_from_scratch/docker-compose.yml @@ -7,9 +7,14 @@ services: environment: EULA: "TRUE" SETUP_ONLY: "TRUE" - VERSION: ${MINECRAFT_VERSION:-LATEST} WHITELIST: itzg ENFORCE_WHITELIST: "true" OVERRIDE_SERVER_PROPERTIES: "true" + # the following are only used to speed up test execution + TYPE: CUSTOM + CUSTOM_SERVER: /servers/fake.jar + VERSION: 1.18.1 volumes: - ./data:/data + # the following are only used to speed up test execution + - ./verify.sh:/servers/fake.jar diff --git a/tests/setuponlytests/world_from_tar/docker-compose.yml b/tests/setuponlytests/world_from_tar/docker-compose.yml index 89aba954301..8f5f58064b1 100644 --- a/tests/setuponlytests/world_from_tar/docker-compose.yml +++ b/tests/setuponlytests/world_from_tar/docker-compose.yml @@ -7,8 +7,13 @@ services: environment: EULA: "TRUE" SETUP_ONLY: "TRUE" - VERSION: ${MINECRAFT_VERSION:-LATEST} WORLD: /worlds/world-for-testing.tar + # the following are only used to speed up test execution + TYPE: CUSTOM + CUSTOM_SERVER: /servers/fake.jar + VERSION: 1.18.1 volumes: - ./worlds:/worlds:ro - ./data:/data + # the following are only used to speed up test execution + - ./verify.sh:/servers/fake.jar