diff --git a/Dockerfile b/Dockerfile index 34db41e6..2a959ba2 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/README.md b/README.md index bb95f1f1..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 @@ -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 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 diff --git a/start b/start index d6c514bf..69ed3d53 100644 --- a/start +++ b/start @@ -4,19 +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 - exec su-exec minecraft:minecraft /start-configuration $@ + if [[ ${SKIP_NSSWITCH_CONF^^} != TRUE ]]; then + echo 'hosts: files dns' > /etc/nsswitch.conf + fi + + exec su-exec ${runAsUser}:${runAsGroup} /start-configuration $@ else exec /start-configuration $@ fi 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 +}