build: perform validation on all base images for PRs (#1610)

This commit is contained in:
Geoff Bourne 2022-07-20 20:24:05 -05:00 committed by GitHub
parent a0a046f9f6
commit eb22d4cadc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 110 additions and 108 deletions

3
.github/FUNDING.yml vendored
View File

@ -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

View File

@ -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

View File

@ -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 }}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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