mirror of
https://github.com/itzg/docker-minecraft-server.git
synced 2026-03-22 06:22:45 +00:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
747c188824 | ||
|
|
692087dd25 | ||
|
|
6fe13e8654 | ||
|
|
3b2b98b9fe | ||
|
|
796f2fe14a | ||
|
|
4fef391b64 | ||
|
|
83f6cebd0b | ||
|
|
90183ae823 | ||
|
|
3c9df03584 | ||
|
|
367c6cfd92 | ||
|
|
5e75410e7c | ||
|
|
38028f7d0c | ||
|
|
a07ae685e2 |
12
.github/workflows/main.yml
vendored
12
.github/workflows/main.yml
vendored
@@ -16,7 +16,18 @@ on:
|
|||||||
- "[0-9]+.[0-9]+.[0-9]+-adopt13"
|
- "[0-9]+.[0-9]+.[0-9]+-adopt13"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: |
|
||||||
|
tests/test.sh
|
||||||
build:
|
build:
|
||||||
|
needs:
|
||||||
|
- test
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
@@ -32,4 +43,5 @@ jobs:
|
|||||||
tag_with_sha: false
|
tag_with_sha: false
|
||||||
cache_froms: itzg/minecraft-server:latest
|
cache_froms: itzg/minecraft-server:latest
|
||||||
add_git_labels: true
|
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
|
push: true
|
||||||
|
|||||||
11
.github/workflows/pr.yml
vendored
11
.github/workflows/pr.yml
vendored
@@ -5,15 +5,12 @@ on:
|
|||||||
branches: [ master ]
|
branches: [ master ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Build Docker image
|
- name: Run tests
|
||||||
uses: docker/build-push-action@v1.1.0
|
run: |
|
||||||
with:
|
tests/test.sh
|
||||||
tag_with_sha: true
|
|
||||||
cache_froms: itzg/minecraft-server:latest
|
|
||||||
push: false
|
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
FROM openjdk:8u212-jre-alpine
|
FROM openjdk:8u212-jre-alpine
|
||||||
|
|
||||||
LABEL maintainer "itzg"
|
LABEL org.opencontainers.image.authors="Geoff Bourne <itzgeoff@gmail.com>"
|
||||||
|
|
||||||
|
# upgrade all packages since alpine jre8 base image tops out at 8u212
|
||||||
|
RUN apk -U --no-cache upgrade
|
||||||
|
|
||||||
RUN apk add --no-cache -U \
|
RUN apk add --no-cache -U \
|
||||||
openssl \
|
openssl \
|
||||||
|
|||||||
@@ -324,7 +324,13 @@ There are some limitations to what characters you can use.
|
|||||||
Variables will be replaced in files with the following extensions:
|
Variables will be replaced in files with the following extensions:
|
||||||
`.yml`, `.yaml`, `.txt`, `.cfg`, `.conf`, `.properties`.
|
`.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`.
|
Here is a full example where we want to replace values inside a `database.yml`.
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,22 @@ if [[ $PROXY ]]; then
|
|||||||
sleep 5
|
sleep 5
|
||||||
fi
|
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 SERVER_PROPERTIES=/data/server.properties
|
||||||
export VERSIONS_JSON=https://launchermeta.mojang.com/mc/game/version_manifest.json
|
export VERSIONS_JSON=https://launchermeta.mojang.com/mc/game/version_manifest.json
|
||||||
|
|
||||||
@@ -129,8 +145,9 @@ case "${TYPE^^}" in
|
|||||||
|
|
||||||
*)
|
*)
|
||||||
log "Invalid type: '$TYPE'"
|
log "Invalid type: '$TYPE'"
|
||||||
log "Must be: VANILLA, FORGE, BUKKIT, SPIGOT, PAPER, FTBA, CURSEFORGE, SPONGEVANILLA,"
|
log "Must be: VANILLA, FORGE, BUKKIT, SPIGOT, PAPER, FTBA (multiarch-only),"
|
||||||
log " CUSTOM, CURSE_INSTANCE, MAGMA, MOHIST, CATSERVER"
|
log " CURSE_INSTANCE, CURSEFORGE, SPONGEVANILLA,"
|
||||||
|
log " CUSTOM, MAGMA, MOHIST, CATSERVER"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
|||||||
@@ -62,8 +62,12 @@ function downloadSpigot {
|
|||||||
downloadUrl="https://cdn.getbukkit.org/${getbukkitFlavor}/${getbukkitFlavor}-${VANILLA_VERSION}.jar"
|
downloadUrl="https://cdn.getbukkit.org/${getbukkitFlavor}/${getbukkitFlavor}-${VANILLA_VERSION}.jar"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -f $SERVER ]; then
|
||||||
|
# tell curl to only download when newer
|
||||||
|
zarg="-z $SERVER"
|
||||||
|
fi
|
||||||
log "Downloading $match from $downloadUrl ..."
|
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
|
if [[ $? != 0 || $(grep -c "DOCTYPE html" $SERVER) != 0 ]]; then
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
|
|
||||||
@@ -89,12 +93,12 @@ case "$TYPE" in
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [ ! -f $SERVER ] || [ -n "$FORCE_REDOWNLOAD" ]; then
|
if isTrue "$BUILD_SPIGOT_FROM_SOURCE" || isTrue "$BUILD_FROM_SOURCE"; then
|
||||||
if isTrue "$BUILD_SPIGOT_FROM_SOURCE" || isTrue "$BUILD_FROM_SOURCE"; then
|
if [ ! -f $SERVER ] || [ -n "$FORCE_REDOWNLOAD" ]; then
|
||||||
buildSpigotFromSource
|
buildSpigotFromSource
|
||||||
else
|
fi
|
||||||
downloadSpigot
|
else
|
||||||
fi
|
downloadSpigot
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Normalize on Spigot for operations below
|
# Normalize on Spigot for operations below
|
||||||
|
|||||||
@@ -5,17 +5,18 @@
|
|||||||
: ${PAPERBUILD:=latest}
|
: ${PAPERBUILD:=latest}
|
||||||
export SERVER=paper_server-${VANILLA_VERSION}-${PAPERBUILD}.jar
|
export SERVER=paper_server-${VANILLA_VERSION}-${PAPERBUILD}.jar
|
||||||
|
|
||||||
if [ ! -f "$SERVER" ] || [ -n "$FORCE_REDOWNLOAD" ]; then
|
if [ -f "$SERVER" ] && ! isTrue "$FORCE_REDOWNLOAD"; then
|
||||||
downloadUrl=${PAPER_DOWNLOAD_URL:-https://papermc.io/api/v1/paper/${VANILLA_VERSION}/${PAPERBUILD}/download}
|
zarg="-z '$SERVER'"
|
||||||
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
|
|
||||||
fi
|
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 TYPE=SPIGOT
|
||||||
export SKIP_LOG4J_CONFIG=true
|
export SKIP_LOG4J_CONFIG=true
|
||||||
|
|
||||||
|
|||||||
@@ -6,15 +6,20 @@
|
|||||||
|
|
||||||
if isTrue "${REPLACE_ENV_VARIABLES}"; then
|
if isTrue "${REPLACE_ENV_VARIABLES}"; then
|
||||||
log "Replacing env variables in configs that match the prefix $ENV_VARIABLE_PREFIX..."
|
log "Replacing env variables in configs that match the prefix $ENV_VARIABLE_PREFIX..."
|
||||||
|
|
||||||
findExcludes=
|
findExcludes=
|
||||||
|
|
||||||
|
# File excludes
|
||||||
for f in ${REPLACE_ENV_VARIABLES_EXCLUDES}; do
|
for f in ${REPLACE_ENV_VARIABLES_EXCLUDES}; do
|
||||||
findExcludes="${findExcludes} -not -name $f"
|
findExcludes="${findExcludes} -not -name $f"
|
||||||
done
|
done
|
||||||
for p in ${REPLACE_ENV_VARIABLES_EXCLUDE_PATHS}; do
|
|
||||||
findExcludes="${findExcludes} -not -path \"*$p*\""
|
# Directory excludes (recursive)
|
||||||
done
|
dirExcludes=$(join_by " -o -path " ${REPLACE_ENV_VARIABLES_EXCLUDE_PATHS})
|
||||||
isDebugging && echo "Using find exclusion: $findExcludes"
|
if [[ $dirExcludes ]]; then
|
||||||
|
findExcludes+=" -type d ( -path ${dirExcludes} ) -prune"
|
||||||
|
fi
|
||||||
|
|
||||||
|
isDebugging && echo "Using find exclusions: $findExcludes"
|
||||||
|
|
||||||
while IFS='=' read -r name value ; do
|
while IFS='=' read -r name value ; do
|
||||||
# check if name of env variable matches the prefix
|
# check if name of env variable matches the prefix
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ else
|
|||||||
worldDest=/data/$LEVEL
|
worldDest=/data/$LEVEL
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$WORLD" ]] && isTrue "${FORCE_WORLD_COPY}" || [ ! -d "$worldDest" ]; then
|
if [[ "$WORLD" ]] && ( isTrue "${FORCE_WORLD_COPY}" || [ ! -d "$worldDest" ] ); then
|
||||||
if isURL $WORLD; then
|
if isURL $WORLD; then
|
||||||
curl -fsSL "$WORLD" -o /tmp/world.zip
|
curl -fsSL "$WORLD" -o /tmp/world.zip
|
||||||
zipSrc=/tmp/world.zip
|
zipSrc=/tmp/world.zip
|
||||||
|
|||||||
@@ -170,13 +170,10 @@ if [[ ${TYPE} == "CURSE_INSTANCE" ]]; then
|
|||||||
elif [[ ${TYPE} == "FEED-THE-BEAST" ]]; then
|
elif [[ ${TYPE} == "FEED-THE-BEAST" ]]; then
|
||||||
mcServerRunnerArgs="${mcServerRunnerArgs} --shell bash"
|
mcServerRunnerArgs="${mcServerRunnerArgs} --shell bash"
|
||||||
|
|
||||||
if [ ! -e "${FTB_DIR}/ops.json" -a -e /data/ops.txt ]; then
|
# copy player modification files unconditionally since their
|
||||||
cp -f /data/ops.txt ${FTB_DIR}/
|
# processing into json is additive anyway
|
||||||
fi
|
[ -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}/whitelist.json" -a -e /data/white-list.txt ]; then
|
|
||||||
cp -f /data/white-list.txt ${FTB_DIR}/
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -e "${FTB_DIR}/server-icon.png" -a -e /data/server-icon.png ]; then
|
if [ ! -e "${FTB_DIR}/server-icon.png" -a -e /data/server-icon.png ]; then
|
||||||
cp -f /data/server-icon.png ${FTB_DIR}/
|
cp -f /data/server-icon.png ${FTB_DIR}/
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
function join_by { local d=$1; shift; echo -n "$1"; shift; printf "%s" "${@/#/$d}"; }
|
||||||
|
|
||||||
function isURL {
|
function isURL {
|
||||||
local value=$1
|
local value=$1
|
||||||
|
|
||||||
|
|||||||
17
tests/docker-compose.test.yml
Normal file
17
tests/docker-compose.test.yml
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
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:
|
||||||
|
restart: "no"
|
||||||
|
build:
|
||||||
|
context: ..
|
||||||
|
cache_from:
|
||||||
|
- itzg/minecraft-server:latest
|
||||||
|
environment:
|
||||||
|
EULA: "TRUE"
|
||||||
|
|
||||||
17
tests/test.sh
Executable file
17
tests/test.sh
Executable file
@@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
if $failed; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
Reference in New Issue
Block a user