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 MAINTAINER itzg
RUN apt-get update
RUN apt-get install -y wget libmozjs-24-bin imagemagick && apt-get clean 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 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 MOTD A Minecraft Server Powered by Docker
ENV LEVEL world ENV LEVEL world
ENV JVM_OPTS -Xmx1024M -Xms1024M ENV JVM_OPTS -Xmx1024M -Xms1024M
ENV TYPE VANILLA
ENV VERSION LATEST ENV VERSION LATEST

View file

@ -56,7 +56,7 @@ replacing 1000 with a UID that is present on the host.
Here is one way to find the UID given a username: Here is one way to find the UID given a username:
grep some_host_user /etc/passwd|cut -d: -f3 grep some_host_user /etc/passwd|cut -d: -f3
## Versions ## Versions
To use a different Minecraft version, pass the `VERSION` environment variable, which can have the value To use a different Minecraft version, pass the `VERSION` environment variable, which can have the value
@ -73,6 +73,26 @@ or a specific version:
docker run -d -e VERSION=1.7.9 ... 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 ## Server configuration
### Op/Administrator Players ### Op/Administrator Players

View file

@ -15,22 +15,60 @@ if [ ! -e /data/eula.txt ]; then
fi fi
fi fi
echo "Checking version information."
case $VERSION in case $VERSION in
LATEST) 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) 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 esac
cd /data cd /data
if [ ! -e minecraft_server.$VERSION.jar ]; then echo "Checking minecraft / forge type information."
echo "Downloading minecraft_server.$VERSION.jar ..." case $TYPE in
wget -q https://s3.amazonaws.com/Minecraft.Download/versions/$VERSION/minecraft_server.$VERSION.jar VANILLA)
fi 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 if [ ! -e server.properties ]; then
cp /tmp/server.properties . cp /tmp/server.properties .
@ -62,7 +100,7 @@ if [ ! -e server.properties ]; then
exit 1 exit 1
;; ;;
esac esac
sed -i "/gamemode\s*=/ c gamemode=$MODE" /data/server.properties sed -i "/gamemode\s*=/ c gamemode=$MODE" /data/server.properties
fi fi
fi fi
@ -85,5 +123,4 @@ if [ -n "$ICON" -a ! -e server-icon.png ]; then
fi fi
fi fi
exec java $JVM_OPTS -jar minecraft_server.$VERSION.jar exec java $JVM_OPTS -jar $SERVER