From 9fa27b9a3d49f789b78dc3062da7f288ba1f7ac4 Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Fri, 1 Jan 2016 12:39:43 -0600 Subject: [PATCH 1/7] [mc] Adding MODPACK download option similar to WORLD --- minecraft-server/Dockerfile | 2 +- minecraft-server/README.md | 11 +++++++++++ minecraft-server/start-minecraft.sh | 19 +++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/minecraft-server/Dockerfile b/minecraft-server/Dockerfile index 9d8c84b5..4120dd9b 100644 --- a/minecraft-server/Dockerfile +++ b/minecraft-server/Dockerfile @@ -36,4 +36,4 @@ ENV UID=1000 ENV MOTD A Minecraft Server Powered by Docker ENV JVM_OPTS -Xmx1024M -Xms1024M ENV TYPE=VANILLA VERSION=LATEST FORGEVERSION=RECOMMENDED LEVEL=world PVP=true DIFFICULTY=easy \ - LEVEL_TYPE=DEFAULT GENERATOR_SETTINGS= WORLD= + LEVEL_TYPE=DEFAULT GENERATOR_SETTINGS= WORLD= MODPACK= diff --git a/minecraft-server/README.md b/minecraft-server/README.md index 88a41392..bc80e7f6 100644 --- a/minecraft-server/README.md +++ b/minecraft-server/README.md @@ -301,6 +301,17 @@ will be deleted when the container is deleted. you should use an IP address or a globally resolveable FQDN, or else the name of a linked container. +### Downloadable mod pack + +Like the `WORLD` option above, you can specify the URL of a "mod pack" +to download and install into the `mods` directory. To use this option +pass the environment variable `MODPACK`, such as + + docker run -d -e MODPACK=http://www.example.com/mods/modpack.zip ... + +**NOTE:** The referenced URL must be a zip file with one or more Forge jar files at the +top level of the zip archive. + ## JVM Configuration ### Memory Limit diff --git a/minecraft-server/start-minecraft.sh b/minecraft-server/start-minecraft.sh index 92513ab0..d7738344 100755 --- a/minecraft-server/start-minecraft.sh +++ b/minecraft-server/start-minecraft.sh @@ -90,6 +90,7 @@ case "$TYPE" in esac # If supplied with a URL for a world, download it and unpack +if [[ "$WORLD" ]]; then case "X$WORLD" in X[Hh][Tt][Tt][Pp]*[Zz][iI][pP]) echo "Downloading world via HTTP" @@ -113,6 +114,24 @@ case "X$WORLD" in echo "Invalid URL given for world: Must be HTTP or HTTPS and a ZIP file" ;; esac +fi + +# If supplied with a URL for a modpack (simple zip of jars), download it and unpack +if [[ "$MODPACK" ]]; then +case "X$MODPACK" in + X[Hh][Tt][Tt][Pp]*[Zz][iI][pP]) + echo "Downloading mod pack via HTTP" + echo "$MODPACK" + mkdir -p /data/mods + wget -q -O /tmp/modpack.zip "$MODPACK" + unzip -d /data/mods /tmp/modpack.zip + rm -f /tmp/modpack.zip + ;; + *) + echo "Invalid URL given for modpack: Must be HTTP or HTTPS and a ZIP file" + ;; +esac +fi if [ ! -e server.properties ]; then cp /tmp/server.properties . From 4ab31a049b75521b417d1322903c25be2a87c9a6 Mon Sep 17 00:00:00 2001 From: Steve Shipway Date: Sat, 2 Jan 2016 11:33:05 +1300 Subject: [PATCH 2/7] Allow non-ZIP urls for download Add directory rename for Spigot --- minecraft-server/start-minecraft.sh | 53 +++++++++++++++++++---------- 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/minecraft-server/start-minecraft.sh b/minecraft-server/start-minecraft.sh index 92513ab0..b4d2dd3a 100755 --- a/minecraft-server/start-minecraft.sh +++ b/minecraft-server/start-minecraft.sh @@ -33,19 +33,15 @@ esac cd /data -echo "Checking minecraft / forge type information." +echo "Checking type information." case "$TYPE" in - VANILLA) - SERVER="minecraft_server.$VANILLA_VERSION.jar" + *BUKKIT|*bukkit|SPIGOT|spigot) + TYPE=SPIGOT + ;; - if [ ! -e $SERVER ]; then - echo "Downloading $SERVER ..." - wget -q https://s3.amazonaws.com/Minecraft.Download/versions/$VANILLA_VERSION/$SERVER - fi - ;; - - FORGE) + FORGE|forge) # norm := the official Minecraft version as Forge is tracking it. dropped the third part starting with 1.8 + TYPE=FORGE case $VANILLA_VERSION in 1.7.*) norm=$VANILLA_VERSION @@ -56,16 +52,16 @@ case "$TYPE" in ;; esac - echo "Checking Forge version information." - case $FORGEVERSION in - RECOMMENDED) + echo "Checking Forge version information." + case $FORGEVERSION in + RECOMMENDED) FORGE_VERSION=`wget -O - http://files.minecraftforge.net/maven/net/minecraftforge/forge/promotions_slim.json | jsawk -n "out(this.promos['$norm-recommended'])"` - ;; + ;; - *) + *) FORGE_VERSION=$FORGEVERSION - ;; - esac + ;; + esac # URL format changed for 1.7.10 from 10.13.2.1300 sorted=$((echo $FORGE_VERSION; echo 10.13.2.1300) | sort -V | head -1) @@ -87,11 +83,26 @@ case "$TYPE" in fi ;; + VANILLA|vanilla|) + SERVER="minecraft_server.$VANILLA_VERSION.jar" + + if [ ! -e $SERVER ]; then + echo "Downloading $SERVER ..." + wget -q https://s3.amazonaws.com/Minecraft.Download/versions/$VANILLA_VERSION/$SERVER + fi + ;; + + *) + echo "Invalid type: '$TYPE'" + echo "Must be: VANILLA, FORGE, SPIGOT" + exit 1 + ;; + esac # If supplied with a URL for a world, download it and unpack case "X$WORLD" in - X[Hh][Tt][Tt][Pp]*[Zz][iI][pP]) + X[Hh][Tt][Tt][Pp]*) echo "Downloading world via HTTP" echo "$WORLD" wget -q -O - "$WORLD" > /data/world.zip @@ -108,6 +119,12 @@ case "X$WORLD" in fi done fi + if [ "$TYPE" = "SPIGOT" ]; then + # Reorganise if a Spigot server + echo "Moving End and Nether maps to Spigot location" + [ -d "/data/world/DIM1" ] && mv -f "/data/world/DIM1" "/data/world_the_end" + [ -d "/data/world/DIM-1" ] && mv -f "/data/world/DIM-1" "/data/world_nether" + fi ;; *) echo "Invalid URL given for world: Must be HTTP or HTTPS and a ZIP file" From d0263f31d6a8d65201861e4f0f1377d2dfa2f979 Mon Sep 17 00:00:00 2001 From: Steve Shipway Date: Sat, 2 Jan 2016 12:12:20 +1300 Subject: [PATCH 3/7] Add bukkit/spigot type download --- minecraft-server/start-minecraft.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/minecraft-server/start-minecraft.sh b/minecraft-server/start-minecraft.sh index b4d2dd3a..98158858 100755 --- a/minecraft-server/start-minecraft.sh +++ b/minecraft-server/start-minecraft.sh @@ -37,6 +37,26 @@ echo "Checking type information." case "$TYPE" in *BUKKIT|*bukkit|SPIGOT|spigot) TYPE=SPIGOT + case "$TYPE" in + *BUKKIT|*bukkit) + echo "Downloading latest CraftBukkit 1.8 server ..." + SERVER=craftbukkit_server.jar + ;; + *) + echo "Downloading latest Spigot 1.8 server ..." + SERVER=spigot_server.jar + ;; + esac + case $VANILLA_VERSION in + 1.8*) + URL=/spigot18/$SERVER + ;; + *) + echo "That version of $SERVER is not available." + exit 1 + ;; + esac + wget -q https://getspigot.org$URL ;; FORGE|forge) From 13a6d912955de5420d4cc9f8a3e395ac8a138811 Mon Sep 17 00:00:00 2001 From: Steve Shipway Date: Sat, 2 Jan 2016 12:20:39 +1300 Subject: [PATCH 4/7] Fix typo --- minecraft-server/start-minecraft.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/minecraft-server/start-minecraft.sh b/minecraft-server/start-minecraft.sh index 98158858..0eae5c40 100755 --- a/minecraft-server/start-minecraft.sh +++ b/minecraft-server/start-minecraft.sh @@ -103,7 +103,7 @@ case "$TYPE" in fi ;; - VANILLA|vanilla|) + VANILLA|vanilla) SERVER="minecraft_server.$VANILLA_VERSION.jar" if [ ! -e $SERVER ]; then From 582c60cd0362fea6b926375892f57fd65efd60db Mon Sep 17 00:00:00 2001 From: Steve Shipway Date: Sat, 2 Jan 2016 13:11:07 +1300 Subject: [PATCH 5/7] Add /plugins mount for external bukkit plugins Add TYPE=BUKKIT documentation --- minecraft-server/Dockerfile | 4 ++- minecraft-server/README.md | 51 +++++++++++++++++++++++++++++ minecraft-server/start-minecraft.sh | 7 +++- 3 files changed, 60 insertions(+), 2 deletions(-) diff --git a/minecraft-server/Dockerfile b/minecraft-server/Dockerfile index 9d8c84b5..3eacc391 100644 --- a/minecraft-server/Dockerfile +++ b/minecraft-server/Dockerfile @@ -14,7 +14,8 @@ RUN useradd -M -s /bin/false --uid 1000 minecraft \ && mkdir /data \ && mkdir /config \ && mkdir /mods \ - && chown minecraft:minecraft /data /config /mods + && mkdir /plugins + && chown minecraft:minecraft /data /config /mods /plugins EXPOSE 25565 @@ -24,6 +25,7 @@ COPY start-minecraft.sh /start-minecraft VOLUME ["/data"] VOLUME ["/mods"] VOLUME ["/config"] +VOLUME ["/plugins"] COPY server.properties /tmp/server.properties WORKDIR /data diff --git a/minecraft-server/README.md b/minecraft-server/README.md index 88a41392..5120e20d 100644 --- a/minecraft-server/README.md +++ b/minecraft-server/README.md @@ -146,6 +146,57 @@ This works well if you want to have a common set of modules in a separate location, but still have multiple worlds with different server requirements in either persistent volumes or a downloadable archive. +## Running a Bukkit/Spigot server + +Enable Bukkit/Spigot server mode by adding a `-e TYPE=BUKKIT -e VERSION=1.8` or `-e TYPE=SPIGOT -e VERSION=1.8` to your command-line. + +The VERSION option should be set to 1.8, as this is the only version of CraftBukkit and Spigot currently +available. The latest build in this branch will be used. + + $ docker run -d -v /path/on/host:/data \ + -e TYPE=SPIGOT -e VERSION=1.8 \ + -p 25565:25565 -e EULA=TRUE --name mc itzg/minecraft-server + +You can install Bukkit plugins in two ways. + +### Using the /data volume + +This is the easiest way if you are using a persistent `/data` mount. + +To do this, you will need to attach the container's `/data` directory +(see "Attaching data directory to host filesystem”). +Then, you can add plugins to the `/path/on/host/plugins` folder you chose. From the example above, +the `/path/on/host` folder contents look like: + +``` +/path/on/host +├── plugins +│   └── ... INSTALL PLUGINS HERE ... +├── ops.json +├── server.properties +├── whitelist.json +└── ... +``` + +If you add plugins while the container is running, you'll need to restart it to pick those +up: + + docker stop mc + docker start mc + +### Using separate mounts + +This is the easiest way if you are using an ephemeral `/data` filesystem, +or downloading a world with the `WORLD` option. + +There is one additional volume that can be mounted; `/plugins`. +Any files in this filesystem will be copied over to the main +`/data/plugins` filesystem before starting Minecraft. + +This works well if you want to have a common set of plugins in a separate +location, but still have multiple worlds with different server requirements +in either persistent volumes or a downloadable archive. + ## Using Docker Compose Rather than type the server options below, the port mappings above, etc diff --git a/minecraft-server/start-minecraft.sh b/minecraft-server/start-minecraft.sh index 0eae5c40..a3bf8035 100755 --- a/minecraft-server/start-minecraft.sh +++ b/minecraft-server/start-minecraft.sh @@ -289,6 +289,11 @@ do cp -rf "$c" /data/config fi done - +if [ "$TYPE" = "SPIGOT" ]; then + echo Copying any Bukkit plugins over + if [ -d /plugins ]; then + cp -r /plugins /data + fi +fi exec java $JVM_OPTS -jar $SERVER From 9a90acab23f1d58af1aa0f217047ab57ea515b71 Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Fri, 1 Jan 2016 22:23:26 -0600 Subject: [PATCH 6/7] [mc] Fixed typo in Dockerfile --- minecraft-server/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/minecraft-server/Dockerfile b/minecraft-server/Dockerfile index e03f229d..d30a6ebb 100644 --- a/minecraft-server/Dockerfile +++ b/minecraft-server/Dockerfile @@ -14,7 +14,7 @@ RUN useradd -M -s /bin/false --uid 1000 minecraft \ && mkdir /data \ && mkdir /config \ && mkdir /mods \ - && mkdir /plugins + && mkdir /plugins \ && chown minecraft:minecraft /data /config /mods /plugins EXPOSE 25565 From 1be18346ce9d6789145acf758c947cb0730e5ad8 Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Sun, 3 Jan 2016 09:37:27 -0600 Subject: [PATCH 7/7] [mc] Add Bukkit/Spigot support to MODPACK download-install --- minecraft-server/README.md | 11 ++++++----- minecraft-server/start-minecraft.sh | 11 ++++++++--- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/minecraft-server/README.md b/minecraft-server/README.md index 3d6763e2..ef671b4c 100644 --- a/minecraft-server/README.md +++ b/minecraft-server/README.md @@ -352,16 +352,17 @@ will be deleted when the container is deleted. you should use an IP address or a globally resolveable FQDN, or else the name of a linked container. -### Downloadable mod pack +### Downloadable mod/plugin pack for Forge, Bukkit, and Spigot Servers Like the `WORLD` option above, you can specify the URL of a "mod pack" -to download and install into the `mods` directory. To use this option -pass the environment variable `MODPACK`, such as +to download and install into `mods` for Forge or `plugins` for Bukkit/Spigot. +To use this option pass the environment variable `MODPACK`, such as docker run -d -e MODPACK=http://www.example.com/mods/modpack.zip ... -**NOTE:** The referenced URL must be a zip file with one or more Forge jar files at the -top level of the zip archive. +**NOTE:** The referenced URL must be a zip file with one or more jar files at the +top level of the zip archive. Make sure the jars are compatible with the +particular `TYPE` of server you are running. ## JVM Configuration diff --git a/minecraft-server/start-minecraft.sh b/minecraft-server/start-minecraft.sh index 05ecfabb..3dbfa371 100755 --- a/minecraft-server/start-minecraft.sh +++ b/minecraft-server/start-minecraft.sh @@ -157,11 +157,16 @@ fi if [[ "$MODPACK" ]]; then case "X$MODPACK" in X[Hh][Tt][Tt][Pp]*[Zz][iI][pP]) - echo "Downloading mod pack via HTTP" + echo "Downloading mod/plugin pack via HTTP" echo "$MODPACK" - mkdir -p /data/mods wget -q -O /tmp/modpack.zip "$MODPACK" - unzip -d /data/mods /tmp/modpack.zip + if [ "$TYPE" = "SPIGOT" ]; then + mkdir -p /data/plugins + unzip -d /data/plugins /tmp/modpack.zip + else + mkdir -p /data/mods + unzip -d /data/mods /tmp/modpack.zip + fi rm -f /tmp/modpack.zip ;; *)