Compare commits

...

20 Commits

Author SHA1 Message Date
Geoff Bourne
d00f9d3609 Normalize EULA value to lowercase to match Forge expectations
For #394
2019-10-01 13:54:14 -05:00
Geoff Bourne
5ad745de75 Initial support for GENERIC_PACK
For #392
2019-09-29 11:45:39 -05:00
Pavel Andreyev
b67580af2c Support .conf extension for config files (#388)
* Support .conf extension for config files

* Update the docs for env variables
2019-09-24 10:21:59 -05:00
Geoff Bourne
2900062df5 Always update whitelist from env since it is processed additive anyway
For #283
2019-09-22 16:48:59 -05:00
Geoff Bourne
67fe8931dd Upgrade easy-add, which now logs to stdout 2019-09-22 16:40:54 -05:00
Geoff Bourne
e6f593e8c4 Updating tools to support ARCH=386 builds 2019-09-18 21:14:08 -05:00
Geoff Bourne
8924740cfe Bump mc-server-runner to 1.3.3 to allow for 386 builds 2019-09-17 21:06:29 -05:00
Björn Richter
34d4ae0b59 Only write EULA when it's set to TRUE (#387)
* Only write EULA when it's set to `TRUE`

- This prevents a false value to be written while not being able to correct it afterwards using the environment variable.

* Convert EULA value to upper case to allow lower case `true` as value
2019-09-15 17:15:33 -05:00
Geoff Bourne
62a4541df5 Fix upgrade support for Paper
For #361
2019-09-15 14:09:27 -05:00
Geoff Bourne
401958c0d6 Add debugs for Fabric setup
For #361
2019-09-15 09:54:13 -05:00
Geoff Bourne
8859d223bf Track Minecraft version also in Fabric install marker
For #361
2019-09-14 22:29:54 -05:00
Geoff Bourne
621962ad9c Always populate ops.txt to allow for additive config
For #283
2019-09-08 17:22:20 -05:00
Aurélien Bertron
5c238af3df Add spawn protection setting (#386) 2019-09-08 16:40:45 -05:00
Geoff Bourne
8e148095f0 Adding link for github README 2019-08-24 11:12:41 -05:00
DocQuantum
3c55a05b1c Added ability to add resource-pack from environment vars (#379) 2019-08-24 10:38:59 -05:00
Geoff Bourne
d293a65f5e Add MEMORY example
Fixes #377
2019-08-17 14:40:51 -05:00
Geoff Bourne
e6bfa01db5 Revert "Switch to OpenJ9 base image (#360)"
This reverts commit 93197ffb
2019-08-10 17:47:46 -05:00
Geoff Bourne
4e122a67d3 Added description of CONSOLE=FALSE option (#80) 2019-08-10 17:47:26 -05:00
Geoff Bourne
b11863d3b2 Delegate ToF buildtools inclusion to extending images (#331) 2019-08-10 17:05:23 -05:00
Geoff Bourne
93197ffb77 Switch to OpenJ9 base image (#360) 2019-08-10 17:04:38 -05:00
10 changed files with 112 additions and 55 deletions

View File

@@ -31,39 +31,20 @@ EXPOSE 25565 25575
RUN echo 'hosts: files dns' > /etc/nsswitch.conf RUN echo 'hosts: files dns' > /etc/nsswitch.conf
ARG RESTIFY_VER=1.1.6
ARG RCON_CLI_VER=1.4.6
ARG MC_SERVER_RUNNER_VER=1.3.2
ARG TOF_BUILDTOOLS_VER=1.2.0
ARG ARCH=amd64 ARG ARCH=amd64
ADD https://github.com/itzg/restify/releases/download/${RESTIFY_VER}/restify_${RESTIFY_VER}_linux_${ARCH}.tar.gz /tmp/restify.tgz ARG EASY_ADD_VER=0.3.0
RUN tar -x -C /usr/local/bin -f /tmp/restify.tgz restify && \ ADD https://github.com/itzg/easy-add/releases/download/${EASY_ADD_VER}/easy-add_${EASY_ADD_VER}_linux_${ARCH} /usr/bin/easy-add
rm /tmp/restify.tgz RUN chmod +x /usr/bin/easy-add
ADD https://github.com/itzg/rcon-cli/releases/download/${RCON_CLI_VER}/rcon-cli_${RCON_CLI_VER}_linux_${ARCH}.tar.gz /tmp/rcon-cli.tgz ARG RESTIFY_VER=1.2.1
RUN tar -x -C /usr/local/bin -f /tmp/rcon-cli.tgz rcon-cli && \ RUN easy-add --file restify --from https://github.com/itzg/restify/releases/download/${RESTIFY_VER}/restify_${RESTIFY_VER}_linux_${ARCH}.tar.gz
rm /tmp/rcon-cli.tgz
ADD https://github.com/itzg/mc-server-runner/releases/download/${MC_SERVER_RUNNER_VER}/mc-server-runner_${MC_SERVER_RUNNER_VER}_linux_${ARCH}.tar.gz /tmp/mc-server-runner.tgz ARG RCON_CLI_VER=1.4.7
RUN tar -x -C /usr/local/bin -f /tmp/mc-server-runner.tgz mc-server-runner && \ RUN easy-add --file rcon-cli --from https://github.com/itzg/rcon-cli/releases/download/${RCON_CLI_VER}/rcon-cli_${RCON_CLI_VER}_linux_${ARCH}.tar.gz
rm /tmp/mc-server-runner.tgz
ADD https://git.faldoria.de/tof/server/build-tools/-/jobs/artifacts/buildtools-${TOF_BUILDTOOLS_VER}/raw/target/ToF-BuildTools.jar?job=release-artifact /tmp/tof-buildtools/BuildTools.jar ARG MC_RUN_VER=1.3.3
RUN easy-add --file mc-server-runner --from https://github.com/itzg/mc-server-runner/releases/download/${MC_RUN_VER}/mc-server-runner_${MC_RUN_VER}_linux_${ARCH}.tar.gz
ONBUILD ARG BUILDTOOLS_OUTPUT=/plugins
ONBUILD COPY *Dockerfile* *plugins.yml /tmp/tof-buildtools/
ONBUILD RUN \
[ -d /tmp/tof-buildtools ] && \
[ $(find /tmp/tof-buildtools -type f -name plugins.yml | wc -l) -gt 0 ] && \
java -jar /tmp/tof-buildtools/BuildTools.jar \
--config "/tmp/tof-buildtools/plugins.yml" \
--configs "plugins.yml" \
--dir "/tmp/tof-buildtools/" \
--output ${BUILDTOOLS_OUTPUT} && \
chown -R minecraft:minecraft ${BUILDTOOLS_OUTPUT} && \
rm -fR /tmp/tof-buildtools/ || \
true
COPY mcadmin.jq /usr/share COPY mcadmin.jq /usr/share
RUN chmod +x /usr/local/bin/* RUN chmod +x /usr/local/bin/*
@@ -78,6 +59,7 @@ ENV UID=1000 GID=1000 \
JVM_XX_OPTS="-XX:+UseG1GC" MEMORY="1G" \ JVM_XX_OPTS="-XX:+UseG1GC" MEMORY="1G" \
TYPE=VANILLA VERSION=LATEST FORGEVERSION=RECOMMENDED SPONGEBRANCH=STABLE SPONGEVERSION= FABRICVERSION=LATEST LEVEL=world \ TYPE=VANILLA VERSION=LATEST FORGEVERSION=RECOMMENDED SPONGEBRANCH=STABLE SPONGEVERSION= FABRICVERSION=LATEST LEVEL=world \
PVP=true DIFFICULTY=easy ENABLE_RCON=true RCON_PORT=25575 RCON_PASSWORD=minecraft \ PVP=true DIFFICULTY=easy ENABLE_RCON=true RCON_PORT=25575 RCON_PASSWORD=minecraft \
RESOURCE_PACK= RESOURCE_PACK_SHA1= \
LEVEL_TYPE=DEFAULT GENERATOR_SETTINGS= WORLD= MODPACK= MODS= SERVER_PORT=25565 ONLINE_MODE=TRUE CONSOLE=true SERVER_NAME="Dedicated Server" \ LEVEL_TYPE=DEFAULT GENERATOR_SETTINGS= WORLD= MODPACK= MODS= SERVER_PORT=25565 ONLINE_MODE=TRUE CONSOLE=true SERVER_NAME="Dedicated Server" \
REPLACE_ENV_VARIABLES="FALSE" ENV_VARIABLE_PREFIX="CFG_" REPLACE_ENV_VARIABLES="FALSE" ENV_VARIABLE_PREFIX="CFG_"

View File

@@ -9,6 +9,8 @@ This docker image provides a Minecraft Server that will automatically download t
version at startup. You can also run/upgrade to any specific version or the version at startup. You can also run/upgrade to any specific version or the
latest snapshot. See the *Versions* section below for more information. latest snapshot. See the *Versions* section below for more information.
[![Click for more docs](https://i.imgur.com/jS02ebD.png)](https://github.com/itzg/docker-minecraft-server/blob/master/README.md)
To simply use the latest stable version, run To simply use the latest stable version, run
docker run -d -p 25565:25565 --name mc itzg/minecraft-server docker run -d -p 25565:25565 --name mc itzg/minecraft-server
@@ -238,6 +240,9 @@ There are some limitations to what characters you can use.
| Name | `0-9a-zA-Z_-` | | Name | `0-9a-zA-Z_-` |
| Value | `0-9a-zA-Z_-:/=?.+` | | Value | `0-9a-zA-Z_-:/=?.+` |
Variables will be replaced in files with the following extensions:
`.yml`, `.yaml`, `.txt`, `.cfg`, `.conf`, `.properties`.
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`.
```yml ```yml
@@ -821,6 +826,12 @@ Determines if monsters will be spawned.
Determines if villagers will be spawned. Determines if villagers will be spawned.
docker run -d -e SPAWN_NPCS=true docker run -d -e SPAWN_NPCS=true
### Set spawn protection
Sets the area that non-ops can not edit (0 to disable)
docker run -d -e SPAWN_PROTECTION=0
### View Distance ### View Distance
Sets the amount of world data the server sends the client, measured in chunks in each direction of the player (radius, not diameter). Sets the amount of world data the server sends the client, measured in chunks in each direction of the player (radius, not diameter).
@@ -894,6 +905,14 @@ For example (just the `-e` bits):
-e LEVEL_TYPE=flat -e 'GENERATOR_SETTINGS=3;minecraft:bedrock,3*minecraft:stone,52*minecraft:sandstone;2;' -e LEVEL_TYPE=flat -e 'GENERATOR_SETTINGS=3;minecraft:bedrock,3*minecraft:stone,52*minecraft:sandstone;2;'
### Custom Server Resource Pack
You can set a link to a custom resource pack and set it's checksum using the `RESOURCE_PACK` and `RESOURCE_PACK_SHA1` options respectively, the default is blank:
docker run -d -e 'RESROUCE_PACK=http\://link.com/to/pack.zip?\=1' -e 'RESOURCE_PACK_SHA1=d5db29cd03a2ed055086cef9c31c252b4587d6d0'
**NOTE:** `:` and `=` must be escaped using `\`. The checksum plain-text hexadecimal.
### World Save Name ### World Save Name
You can either switch between world saves or run multiple containers with different saves by using the `LEVEL` option, You can either switch between world saves or run multiple containers with different saves by using the `LEVEL` option,
@@ -1004,7 +1023,9 @@ ways to adjust the memory settings:
* `MAX_MEMORY`, independently sets the max heap size * `MAX_MEMORY`, independently sets the max heap size
The values of all three are passed directly to the JVM and support format/units as The values of all three are passed directly to the JVM and support format/units as
`<size>[g|G|m|M|k|K]`. `<size>[g|G|m|M|k|K]`. For example:
-e MEMORY=2G
### JVM Options ### JVM Options
@@ -1022,3 +1043,13 @@ environment variable. In [the example compose file](docker-compose-proxied.yml)
a companion squid proxy by setting the equivalent of a companion squid proxy by setting the equivalent of
-e PROXY=proxy:3128 -e PROXY=proxy:3128
### Using "noconsole" option
Some older versions of Spigot required `--noconsole` to be passed when detaching stdin. You can
pass that at the end of `docker run` after the image name or set `-e CONSOLE=FALSE`.
### Explicitly disable GUI
Some older servers get confused and think that the GUI interface is enabled. You can explicitly
disable that by passing `-e GUI=FALSE`.

View File

@@ -6,14 +6,8 @@ shopt -s nullglob
export HOME=/data export HOME=/data
if [ ! -e /data/eula.txt ]; then if [ ! -e /data/eula.txt ]; then
if [ "$EULA" != "" ]; then EULA="${EULA,,}"
echo "# Generated via Docker on $(date)" > eula.txt if [ "$EULA" != "true" ]; then
echo "eula=$EULA" >> eula.txt
if [ $? != 0 ]; then
echo "ERROR: unable to write eula to /data. Please make sure attached directory is writable by uid=${UID}"
exit 2
fi
else
echo "" echo ""
echo "Please accept the Minecraft EULA at" echo "Please accept the Minecraft EULA at"
echo " https://account.mojang.com/documents/minecraft_eula" echo " https://account.mojang.com/documents/minecraft_eula"
@@ -22,8 +16,16 @@ if [ ! -e /data/eula.txt ]; then
echo "" echo ""
exit 1 exit 1
fi fi
echo "# Generated via Docker on $(date)" > eula.txt
echo "eula=$EULA" >> eula.txt
if [ $? != 0 ]; then
echo "ERROR: unable to write eula to /data. Please make sure attached directory is writable by uid=${UID}"
exit 2
fi
fi fi
echo "Running as uid=$(id -u) gid=$(id -g) with /data as '$(ls -lnd /data)'" echo "Running as uid=$(id -u) gid=$(id -g) with /data as '$(ls -lnd /data)'"
if ! touch /data/.verify_access; then if ! touch /data/.verify_access; then

View File

@@ -1,5 +1,7 @@
#!/bin/bash #!/bin/bash
set -u set -eu
. /start-utils
export TYPE=FABRIC export TYPE=FABRIC
@@ -28,8 +30,9 @@ elif [[ ! -e $FABRIC_INSTALLER ]]; then
exit 2 exit 2
fi fi
installMarker=".fabric-installed-${FABRIC_VERSION:-manual}" installMarker=".fabric-installed-${VANILLA_VERSION}-${FABRIC_VERSION:-manual}"
debug Checking for installMarker ${installMarker}
if [[ ! -e $installMarker ]]; then if [[ ! -e $installMarker ]]; then
if [[ ! -e $FABRIC_INSTALLER ]]; then if [[ ! -e $FABRIC_INSTALLER ]]; then
if [[ -z $FABRIC_INSTALLER_URL ]]; then if [[ -z $FABRIC_INSTALLER_URL ]]; then
@@ -46,7 +49,11 @@ if [[ ! -e $installMarker ]]; then
fi fi
fi fi
echo "Installing Fabric $FABRIC_VERSION using $FABRIC_INSTALLER" if isDebugging; then
debug "Installing Fabric $FABRIC_VERSION using $FABRIC_INSTALLER with mcversion ${VANILLA_VERSION}"
else
echo "Installing Fabric $FABRIC_VERSION using $FABRIC_INSTALLER"
fi
tries=3 tries=3
set +e set +e
while ((--tries >= 0)); do while ((--tries >= 0)); do

View File

@@ -1,11 +1,11 @@
#!/bin/bash #!/bin/bash
export SERVER=paper_server.jar export SERVER=paper_server-${VANILLA_VERSION}.jar
if [ ! -f $SERVER ] || [ -n "$FORCE_REDOWNLOAD" ]; then if [ ! -f "$SERVER" ] || [ -n "$FORCE_REDOWNLOAD" ]; then
downloadUrl=${PAPER_DOWNLOAD_URL:-https://papermc.io/api/v1/paper/${VANILLA_VERSION}/latest/download} downloadUrl=${PAPER_DOWNLOAD_URL:-https://papermc.io/api/v1/paper/${VANILLA_VERSION}/latest/download}
echo "Downloading Paper $VANILLA_VERSION from $downloadUrl ..." echo "Downloading Paper $VANILLA_VERSION from $downloadUrl ..."
curl -fsSL -o $SERVER "$downloadUrl" curl -fsSL -o "$SERVER" "$downloadUrl"
if [ ! -f $SERVER ]; then if [ ! -f "$SERVER" ]; then
echo "ERROR: failed to download from $downloadUrl (status=$?)" echo "ERROR: failed to download from $downloadUrl (status=$?)"
exit 3 exit 3
fi fi

View File

@@ -1,5 +1,9 @@
#!/bin/bash #!/bin/bash
set -e
. /start-utils
# CURSE_URL_BASE used in manifest downloads below # CURSE_URL_BASE used in manifest downloads below
CURSE_URL_BASE=${CURSE_URL_BASE:-https://minecraft.curseforge.com/projects} CURSE_URL_BASE=${CURSE_URL_BASE:-https://minecraft.curseforge.com/projects}
@@ -106,4 +110,25 @@ case "X$EFFECTIVE_MANIFEST_URL" in
esac esac
fi fi
if [[ "${GENERIC_PACK}" ]]; then
if isURL "${GENERIC_PACK}"; then
generic_pack_url=${GENERIC_PACK}
GENERIC_PACK=/tmp/$(basename ${generic_pack_url})
echo "Downloading generic pack from ${generic_pack_url} ..."
curl -fsSL -o ${GENERIC_PACK} ${generic_pack_url}
fi
sum_file=/data/.generic_pack.sum
if ! sha256sum -c ${sum_file} -s 2> /dev/null; then
base_dir=/tmp/generic_pack_base
mkdir -p ${base_dir}
unzip -q -d ${base_dir} ${GENERIC_PACK}
depth=$(( ${GENERIC_PACK_STRIP_DIRS:-1} + 1 ))
echo "Applying generic pack, stripping $(( depth - 1 )) level ..."
find ${base_dir} -type d -mindepth $depth -maxdepth $depth -exec cp -r {} /data/ +
rm -rf ${base_dir}
sha256sum ${GENERIC_PACK} > ${sum_file}
fi
fi
exec /start-finalSetup03Modconfig $@ exec /start-finalSetup03Modconfig $@

View File

@@ -49,6 +49,7 @@ function customizeServerProps {
setServerProp "spawn-animals" "$SPAWN_ANIMALS" setServerProp "spawn-animals" "$SPAWN_ANIMALS"
setServerProp "spawn-monsters" "$SPAWN_MONSTERS" setServerProp "spawn-monsters" "$SPAWN_MONSTERS"
setServerProp "spawn-npcs" "$SPAWN_NPCS" setServerProp "spawn-npcs" "$SPAWN_NPCS"
setServerProp "spawn-protection" "$SPAWN_PROTECTION"
setServerProp "generate-structures" "$GENERATE_STRUCTURES" setServerProp "generate-structures" "$GENERATE_STRUCTURES"
setServerProp "view-distance" "$VIEW_DISTANCE" setServerProp "view-distance" "$VIEW_DISTANCE"
setServerProp "hardcore" "$HARDCORE" setServerProp "hardcore" "$HARDCORE"
@@ -70,6 +71,8 @@ function customizeServerProps {
setServerProp "online-mode" "$ONLINE_MODE" setServerProp "online-mode" "$ONLINE_MODE"
setServerProp "allow-flight" "$ALLOW_FLIGHT" setServerProp "allow-flight" "$ALLOW_FLIGHT"
setServerProp "level-type" "${LEVEL_TYPE^^}" setServerProp "level-type" "${LEVEL_TYPE^^}"
setServerProp "resource-pack" "$RESOURCE_PACK"
setServerProp "resource-pack-sha1" "$RESOURCE_PACK_SHA1"
if [ -n "$DIFFICULTY" ]; then if [ -n "$DIFFICULTY" ]; then
case $DIFFICULTY in case $DIFFICULTY in

View File

@@ -1,15 +1,20 @@
#!/bin/bash #!/bin/bash
if [ "$REPLACE_ENV_VARIABLES" = "TRUE" ]; then if [ "${REPLACE_ENV_VARIABLES^^}" = "TRUE" ]; then
echo "Replacing env variables in configs that match the prefix $ENV_VARIABLE_PREFIX..." echo "Replacing env variables in configs that match the prefix $ENV_VARIABLE_PREFIX..."
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
# sanity check environment variables to avoid code injections # sanity check environment variables to avoid code injections
if [[ "$name" = $ENV_VARIABLE_PREFIX* ]] && [[ $value =~ ^[0-9a-zA-Z_:/=?.+\-]*$ ]] && [[ $name =~ ^[0-9a-zA-Z_\-]*$ ]]; then if [[ "$name" = $ENV_VARIABLE_PREFIX* ]] \
echo "Replacing $name with $value ..." && [[ $value =~ ^[0-9a-zA-Z_:/=?.+\-]*$ ]] \
find /data/ -type f \( -name "*.yml" -or -name "*.yaml" -or -name "*.txt" -or -name "*.cfg" -or -name "*.properties" \) -exec sed -i 's#${'"$name"'}#'"$value"'#g' {} \; && [[ $name =~ ^[0-9a-zA-Z_\-]*$ ]]; then
echo "Replacing $name with $value ..."
find /data/ -type f \
\( -name "*.yml" -or -name "*.yaml" -or -name "*.txt" -or -name "*.cfg" \
-or -name "*.conf" -or -name "*.properties" \) \
-exec sed -i 's#${'"$name"'}#'"$value"'#g' {} \;
fi fi
done < <(env) done < <(env)
fi fi
exec /start-minecraftFinalSetup $@ exec /start-minecraftFinalSetup $@

View File

@@ -2,14 +2,16 @@
. /start-utils . /start-utils
if [ -n "$OPS" -a ! -e ops.txt.converted ]; then if [ -n "$OPS" ]; then
echo "Setting ops" echo "Setting/adding ops"
echo $OPS | awk -v RS=, '{print}' >> ops.txt rm -rf ops.txt.converted
echo $OPS | awk -v RS=, '{print}' > ops.txt
fi fi
if [ -n "$WHITELIST" -a ! -e white-list.txt.converted ]; then if [ -n "$WHITELIST" ]; then
echo "Setting whitelist" echo "Setting whitelist"
echo $WHITELIST | awk -v RS=, '{print}' >> white-list.txt rm -rf white-list.txt.converted
echo $WHITELIST | awk -v RS=, '{print}' > white-list.txt
fi fi
if [ -n "$ICON" -a ! -e server-icon.png ]; then if [ -n "$ICON" -a ! -e server-icon.png ]; then

View File

@@ -28,7 +28,7 @@ function isTrue {
} }
function isDebugging { function isDebugging {
if [[ ${DEBUG^^} = TRUE ]]; then if [[ -v DEBUG ]] && [[ ${DEBUG^^} = TRUE ]]; then
return 0 return 0
else else
return 1 return 1