From 5fa33c7813ce22b9e2db607b43fa4ee966101c68 Mon Sep 17 00:00:00 2001 From: hannah98 Date: Thu, 21 Nov 2019 13:50:06 -0600 Subject: [PATCH 1/8] Better handle CurseForge manifest.json (#414) --- start-finalSetup02Modpack | 18 ++++++++++++++---- start-utils | 4 ++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/start-finalSetup02Modpack b/start-finalSetup02Modpack index 782377c0..94b637a0 100644 --- a/start-finalSetup02Modpack +++ b/start-finalSetup02Modpack @@ -78,10 +78,20 @@ done fi if [[ "$MANIFEST" ]]; then -EFFECTIVE_MANIFEST_URL=$(curl -Ls -o /dev/null -w %{url_effective} $MANIFEST) -case "X$EFFECTIVE_MANIFEST_URL" in + if [[ -e "$MANIFEST" ]]; then + EFFECTIVE_MANIFEST_FILE=$MANIFEST + elif isURL "$MANIFEST"; then + EFFECTIVE_MANIFEST_FILE=/tmp/manifest.json + EFFECTIVE_MANIFEST_URL=$(curl -Ls -o /dev/null -w %{url_effective} $MANIFEST) + curl -Ls -o $EFFECTIVE_MANIFEST_FILE "$EFFECTIVE_MANIFEST_URL" + else + echo "MANIFEST='$MANIFEST' is not a valid manifest url or location" + exit 2 + fi + +case "X$EFFECTIVE_MANIFEST_FILE" in X*.json) - if [ -f "${EFFECTIVE_MANIFEST_URL}" ]; then + if [ -f "${EFFECTIVE_MANIFEST_FILE}" ]; then MOD_DIR=${FTB_BASE_DIR:-/data}/mods if [ ! -d "$MOD_DIR" ] then @@ -89,7 +99,7 @@ case "X$EFFECTIVE_MANIFEST_URL" in mkdir -p "$MOD_DIR" fi echo "Starting manifest download..." - cat "${EFFECTIVE_MANIFEST_URL}" | jq -r '.files[] | (.projectID|tostring) + " " + (.fileID|tostring)'| while read -r p f + cat "${EFFECTIVE_MANIFEST_FILE}" | jq -r '.files[] | (.projectID|tostring) + " " + (.fileID|tostring)'| while read -r p f do if [ ! -f $MOD_DIR/${p}_${f}.jar ] then diff --git a/start-utils b/start-utils index 8a2cd621..a2aaa18d 100644 --- a/start-utils +++ b/start-utils @@ -3,7 +3,7 @@ function isURL { local value=$1 - if [[ ${value:0:8} == "https://" || ${value:0:7} = "http://" ]]; then + if [[ ${value:0:8} == "https://" || ${value:0:7} == "http://" ]]; then return 0 else return 1 @@ -39,4 +39,4 @@ function debug { if isDebugging; then echo "DEBUG: $*" fi -} \ No newline at end of file +} From 1c9bbee3b3096ae8ce954ba9f3eb569d6e8e37e6 Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Sat, 23 Nov 2019 14:08:16 -0600 Subject: [PATCH 2/8] docs: update proxy section with correct env vars Fixes #415 --- README.md | 6 ++---- examples/docker-compose-proxied.yml | 16 ---------------- 2 files changed, 2 insertions(+), 20 deletions(-) delete mode 100644 examples/docker-compose-proxied.yml diff --git a/README.md b/README.md index bb95f1f1..c8562e61 100644 --- a/README.md +++ b/README.md @@ -1038,11 +1038,9 @@ For some cases, if e.g. after removing mods, it could be necessary to startup mi ### HTTP Proxy -You may configure the use of an HTTP/HTTPS proxy by passing the proxy's URL via the `PROXY` -environment variable. In [the example compose file](docker-compose-proxied.yml) it references -a companion squid proxy by setting the equivalent of +You may configure the use of an HTTP/HTTPS proxy by passing the proxy's URL via the `HTTPS_PROXY` and `HTTP_PROXY` environment variables. - -e PROXY=proxy:3128 + -e HTTPS_PROXY=proxy:3128 ### Using "noconsole" option diff --git a/examples/docker-compose-proxied.yml b/examples/docker-compose-proxied.yml deleted file mode 100644 index e116f240..00000000 --- a/examples/docker-compose-proxied.yml +++ /dev/null @@ -1,16 +0,0 @@ -version: '3' - -services: - mc: -# build: . - image: itzg/minecraft-server - ports: - - 25565:25565 - environment: - EULA: "TRUE" -# TYPE: SPIGOT -# VERSION: 1.11.2 - PROXY: proxy:3128 - proxy: - image: sameersbn/squid - From b40187329885ab4704741c4d5cfee4fc05b2fb50 Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Tue, 26 Nov 2019 08:56:29 -0600 Subject: [PATCH 3/8] docs: Revert "update proxy section with correct env vars" This reverts commit 1c9bbee3 Those env vars already get set by the startup script given PROXY --- README.md | 6 ++++-- examples/docker-compose-proxied.yml | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 examples/docker-compose-proxied.yml diff --git a/README.md b/README.md index c8562e61..bb95f1f1 100644 --- a/README.md +++ b/README.md @@ -1038,9 +1038,11 @@ For some cases, if e.g. after removing mods, it could be necessary to startup mi ### HTTP Proxy -You may configure the use of an HTTP/HTTPS proxy by passing the proxy's URL via the `HTTPS_PROXY` and `HTTP_PROXY` environment variables. +You may configure the use of an HTTP/HTTPS proxy by passing the proxy's URL via the `PROXY` +environment variable. In [the example compose file](docker-compose-proxied.yml) it references +a companion squid proxy by setting the equivalent of - -e HTTPS_PROXY=proxy:3128 + -e PROXY=proxy:3128 ### Using "noconsole" option diff --git a/examples/docker-compose-proxied.yml b/examples/docker-compose-proxied.yml new file mode 100644 index 00000000..e116f240 --- /dev/null +++ b/examples/docker-compose-proxied.yml @@ -0,0 +1,16 @@ +version: '3' + +services: + mc: +# build: . + image: itzg/minecraft-server + ports: + - 25565:25565 + environment: + EULA: "TRUE" +# TYPE: SPIGOT +# VERSION: 1.11.2 + PROXY: proxy:3128 + proxy: + image: sameersbn/squid + From 94b037428e78af56a50775e3dfd6285c06d5ab0f Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Tue, 26 Nov 2019 21:34:56 -0600 Subject: [PATCH 4/8] Add SKIP_NSSWITCH_CONF option For #416 --- Dockerfile | 2 -- start | 4 ++++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index bf4a8549..8d900364 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,8 +29,6 @@ RUN addgroup -g 1000 minecraft \ EXPOSE 25565 25575 -RUN echo 'hosts: files dns' > /etc/nsswitch.conf - ARG ARCH=amd64 ARG EASY_ADD_VER=0.3.0 diff --git a/start b/start index d6c514bf..94a654fd 100644 --- a/start +++ b/start @@ -16,6 +16,10 @@ if [ $(id -u) = 0 ]; then chown -R minecraft:minecraft /data fi + if [[ ${SKIP_NSSWITCH_CONF^^} != TRUE ]]; then + echo 'hosts: files dns' > /etc/nsswitch.conf + fi + exec su-exec minecraft:minecraft /start-configuration $@ else exec /start-configuration $@ From 485d7b06128c00743a8638f327d958952449f25f Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Fri, 27 Dec 2019 22:04:16 -0600 Subject: [PATCH 5/8] docs: added info in README about upgrading LATEST/SNAPSHOT versions For #418 --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bb95f1f1..87232abd 100644 --- a/README.md +++ b/README.md @@ -106,9 +106,9 @@ and start the server again with `docker start CONTAINERID` to pick up the new co To use a different Minecraft version, pass the `VERSION` environment variable, which can have the value -* LATEST +* LATEST (the default) * SNAPSHOT -* (or a specific version, such as "1.7.9") +* or a specific version, such as "1.7.9" For example, to use the latest snapshot: @@ -118,6 +118,11 @@ or a specific version: docker run -d -e VERSION=1.7.9 ... +When using "LATEST" or "SNAPSHOT" an upgrade can be performed by simply restarting the container. +During the next startup, if a newer version is available from the respective release channel, then +the new server jar file is downloaded and used. _NOTE: over time you might see older versions of +the server jar remain in the `/data` directory. It is safe to remove those._ + ## Healthcheck This image contains [Dinnerbone's mcstatus](https://github.com/Dinnerbone/mcstatus) and uses From 5b3259b1ef56b5287fe742714e3cf9253d3bbb96 Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Sat, 28 Dec 2019 14:23:04 -0600 Subject: [PATCH 6/8] docs: added Discord chat badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 87232abd..65cc83b6 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Docker Pulls](https://img.shields.io/docker/pulls/itzg/minecraft-server.svg)](https://hub.docker.com/r/itzg/minecraft-server/) [![Docker Stars](https://img.shields.io/docker/stars/itzg/minecraft-server.svg?maxAge=2592000)](https://hub.docker.com/r/itzg/minecraft-server/) [![GitHub Issues](https://img.shields.io/github/issues-raw/itzg/docker-minecraft-server.svg)](https://github.com/itzg/docker-minecraft-server/issues) -[![](https://img.shields.io/gitter/room/itzg/dockerfiles.svg?style=flat)](https://gitter.im/itzg/dockerfiles) +[![Discord](https://img.shields.io/discord/660567679458869252)](https://discord.gg/DXfKpjB) [![](https://img.shields.io/badge/Donate-Buy%20me%20a%20coffee-orange.svg)](https://www.buymeacoffee.com/itzg) This docker image provides a Minecraft Server that will automatically download the latest stable From 949faf16209e9fb6f8e4654d1243debfee9037d2 Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Sun, 29 Dec 2019 15:18:31 -0600 Subject: [PATCH 7/8] docs: added example kube manifest with statefulset --- k8s-examples/using-statefulset.yml | 50 ++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 k8s-examples/using-statefulset.yml diff --git a/k8s-examples/using-statefulset.yml b/k8s-examples/using-statefulset.yml new file mode 100644 index 00000000..92423eb8 --- /dev/null +++ b/k8s-examples/using-statefulset.yml @@ -0,0 +1,50 @@ +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + labels: + app: example + name: example +spec: + replicas: 1 + serviceName: example + selector: + matchLabels: + app: example + template: + metadata: + labels: + app: example + spec: + containers: + - name: mc + image: itzg/minecraft-server + env: + - name: EULA + value: "TRUE" + volumeMounts: + - mountPath: /data + name: data + volumeClaimTemplates: + - metadata: + name: data + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 1Gi +--- +apiVersion: v1 +kind: Service +metadata: + labels: + service: example + name: example +spec: + ports: + - port: 25565 + targetPort: 25565 + selector: + app: example + type: LoadBalancer From e94f6608d22f7368f690081d570cb05872d7f81c Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Fri, 17 Jan 2020 08:27:11 -0600 Subject: [PATCH 8/8] Fixed UID/GID startup logic to properly handle running as root Fixes #425 --- start | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/start b/start index 94a654fd..69ed3d53 100644 --- a/start +++ b/start @@ -4,23 +4,41 @@ umask 0002 chmod g+w /data if [ $(id -u) = 0 ]; then - if [[ -v UID && $UID != $(id -u) ]]; then - usermod -u $UID minecraft + runAsUser=minecraft + runAsGroup=minecraft + + if [[ -v UID ]]; then + if [[ $UID != 0 ]]; then + if [[ $UID != $(id -u minecraft) ]]; then + echo "Changing uid of minecraft to $UID" + usermod -u $UID minecraft + fi + else + runAsUser=root + fi fi + if [[ -v GID ]]; then - groupmod -o -g $GID minecraft + if [[ $GID != 0 ]]; then + if [[ $GID != $(id -g minecraft) ]]; then + echo "Changing gid of minecraft to $GID" + groupmod -o -g $GID minecraft + fi + else + runAsGroup=root + fi fi if [[ $(stat -c "%u" /data) != $UID ]]; then echo "Changing ownership of /data to $UID ..." - chown -R minecraft:minecraft /data + chown -R ${runAsUser}:${runAsGroup} /data fi if [[ ${SKIP_NSSWITCH_CONF^^} != TRUE ]]; then echo 'hosts: files dns' > /etc/nsswitch.conf fi - exec su-exec minecraft:minecraft /start-configuration $@ + exec su-exec ${runAsUser}:${runAsGroup} /start-configuration $@ else exec /start-configuration $@ fi