Merge pull request #17 from itzg/forge-2

Resolves #14
This commit is contained in:
Geoff Bourne 2015-03-05 14:18:17 -06:00
commit 88032acbfb
3 changed files with 72 additions and 13 deletions

View file

@ -2,6 +2,7 @@ FROM itzg/ubuntu-openjdk-7
MAINTAINER itzg
RUN apt-get update
RUN apt-get install -y wget libmozjs-24-bin imagemagick && apt-get clean
RUN update-alternatives --install /usr/bin/js js /usr/bin/js24 100
@ -26,4 +27,5 @@ ENV UID 1000
ENV MOTD A Minecraft Server Powered by Docker
ENV LEVEL world
ENV JVM_OPTS -Xmx1024M -Xms1024M
ENV TYPE VANILLA
ENV VERSION LATEST

View file

@ -73,6 +73,26 @@ or a specific version:
docker run -d -e VERSION=1.7.9 ...
## Running a Forge Server
By default the container will run the selected "vanilla" (aka official) Minecraft server, but
you can also choose to run the `LATEST` or a specific version of a [Forge server](http://www.minecraftforge.net/wiki/).
Enable Forge server mode, by adding a `-e TYPE=FORGE` to your command-line, such as
$ mkdir forge
$ docker run -d -v $(pwd)/forge:/data -e TYPE=FORGE -e VERSION=1.7.10 \
-p 25565:25565 -e EULA=TRUE itzg/minecraft
**NOTE**: You *must* use a host-attached volume of the container's `/data` in order
to access the `mods` directory. [Docker 1.6 has a scheduled feature](https://github.com/docker/docker/pull/10198) to extend `docker cp` to enable
copying files *into* a container -- until then attach the `/data` volume.
If your container is running when adding mods, you'll need to restart it to pick those
up:
docker stop $ID
docker start $ID
## Server configuration
### Op/Administrator Players

View file

@ -15,22 +15,60 @@ if [ ! -e /data/eula.txt ]; then
fi
fi
echo "Checking version information."
case $VERSION in
LATEST)
export VERSION=`wget -O - https://s3.amazonaws.com/Minecraft.Download/versions/versions.json | jsawk -n 'out(this.latest.release)'`
VANILLA_VERSION=`wget -O - https://s3.amazonaws.com/Minecraft.Download/versions/versions.json | jsawk -n 'out(this.latest.release)'`
;;
SNAPSHOT)
export VERSION=`wget -O - https://s3.amazonaws.com/Minecraft.Download/versions/versions.json | jsawk -n 'out(this.latest.snapshot)'`
VANILLA_VERSION=`wget -O - https://s3.amazonaws.com/Minecraft.Download/versions/versions.json | jsawk -n 'out(this.latest.snapshot)'`
;;
*)
VANILLA_VERSION=$VERSION
;;
esac
cd /data
if [ ! -e minecraft_server.$VERSION.jar ]; then
echo "Downloading minecraft_server.$VERSION.jar ..."
wget -q https://s3.amazonaws.com/Minecraft.Download/versions/$VERSION/minecraft_server.$VERSION.jar
echo "Checking minecraft / forge type information."
case $TYPE in
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
;;
FORGE)
# norm := the official Minecraft version as Forge is tracking it. dropped the third part starting with 1.8
case $VANILLA_VERSION in
1.7.*)
echo OLDER
norm=$VANILLA_VERSION
;;
*)
norm=`echo $VANILLA_VERSION | sed 's/^\([0-9]\+\.[0-9]\+\).*/\1/'`
;;
esac
FORGE_VERSION=`wget -O - http://files.minecraftforge.net/maven/net/minecraftforge/forge/promotions_slim.json | jsawk -n "out(this.promos['$norm-latest'])"`
normForgeVersion="$norm-$FORGE_VERSION"
FORGE_INSTALLER="forge-$normForgeVersion-installer.jar"
SERVER="forge-$normForgeVersion-universal.jar"
if [ ! -e $SERVER ]; then
echo "Downloading $FORGE_INSTALLER ..."
wget -q http://files.minecraftforge.net/maven/net/minecraftforge/forge/$normForgeVersion/$FORGE_INSTALLER
echo "Installing $SERVER"
java -jar $FORGE_INSTALLER --installServer
fi
;;
esac
if [ ! -e server.properties ]; then
cp /tmp/server.properties .
@ -85,5 +123,4 @@ if [ -n "$ICON" -a ! -e server-icon.png ]; then
fi
fi
exec java $JVM_OPTS -jar minecraft_server.$VERSION.jar
exec java $JVM_OPTS -jar $SERVER