Dynamically download modpacks at runtime if so desired
This commit is contained in:
		@@ -17,6 +17,7 @@ RUN apk add curl openjdk8-jre &&\
 | 
			
		||||
 | 
			
		||||
# The second stage is the actual container
 | 
			
		||||
FROM openjdk:8
 | 
			
		||||
RUN apt-get update && apt-get install rsync -y
 | 
			
		||||
WORKDIR /minecraft
 | 
			
		||||
COPY --from=build /minecraft .
 | 
			
		||||
CMD [ "bash", "start-server.sh" ]
 | 
			
		||||
 
 | 
			
		||||
@@ -28,6 +28,7 @@ variable|description
 | 
			
		||||
---|---
 | 
			
		||||
`JRE_XMX`|Maximum amount of heap passed to the main Minecraft process
 | 
			
		||||
`JRE_XMS`|Minimum heap size passed to the main Minecraft process
 | 
			
		||||
`FORGE_PACK_ZIP`|If provided, the URL to a zip or tar.gz file that contains the modpack that needs to be installed. Will be intelligently extracted into the server directory through the magic of `find`.
 | 
			
		||||
`ARGS`|Any additional arguments to be passed to the JVM
 | 
			
		||||
 | 
			
		||||
## Useful Arguments
 | 
			
		||||
@@ -47,6 +48,14 @@ enable-command-block=true
 | 
			
		||||
spawn-protection=0
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## FAQ
 | 
			
		||||
 | 
			
		||||
**Why do you download the pack at runtime?**
 | 
			
		||||
 | 
			
		||||
It allows for transparent upgrades without having to build a whole new container. You may lose container consistency, but you gain simplicity in definition.
 | 
			
		||||
 | 
			
		||||
Of course, nothing prevents you from just not using this magic variable and instead `FROM`ing this container and building your own pack.
 | 
			
		||||
 | 
			
		||||
## License
 | 
			
		||||
 | 
			
		||||
MIT
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,20 @@
 | 
			
		||||
#
 | 
			
		||||
# Distributed under terms of the MIT license.
 | 
			
		||||
#
 | 
			
		||||
set -e
 | 
			
		||||
 | 
			
		||||
# Download and extract a pack zip, if one is provided
 | 
			
		||||
if [ -n "$FORGE_PACK_ZIP" ]; then
 | 
			
		||||
	echo "Downloading pack: $FORGE_PACK_ZIP"
 | 
			
		||||
	tmpdir="$(mktemp -d)"
 | 
			
		||||
	pushd "$tmpdir" > /dev/null 2>&1
 | 
			
		||||
	curl -L "$FORGE_PACK_ZIP" -o pack.zip
 | 
			
		||||
	unzip pack.zip
 | 
			
		||||
	directory="$(find . -type d -iname "mods" -execdir pwd \; | sort -n | head -n 1)"
 | 
			
		||||
	echo "Found modpack directory: $directory"
 | 
			
		||||
	rsync -av "$directory"/ /minecraft/
 | 
			
		||||
	popd > /dev/null 2>&1
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# Entrypoint will be server.jar
 | 
			
		||||
args="-jar server.jar nogui"
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user