Build spigot using buildtools (#67)

* Download buildtools

* Download buildtools

* Not a good idea to chmod /root

* Remove bukkit code

* fix jar not found

* Run start-minecraft as root (temp)

* Working buildtools

* Remove echo line

* Added more server properties, not working yet

* Show what server properties are being added

* Show what server properties are being added

* Add rcon.password

* Add max-world-size

* Added alot of server settings

* Expose rcon port

* Export home per itzg suggestion

* Update readme and server properties

* Env for building spigot from source

* Update readme
This commit is contained in:
Sander
2016-04-16 18:26:13 +02:00
committed by Geoff Bourne
parent 21c9be4ec1
commit a4835ec331
5 changed files with 287 additions and 32 deletions

View File

@@ -25,6 +25,7 @@ RUN useradd -M -s /bin/false --uid 1000 minecraft \
&& chown minecraft:minecraft /data /config /mods /plugins
EXPOSE 25565
EXPOSE 25575
COPY start.sh /start
COPY start-minecraft.sh /start-minecraft

View File

@@ -164,6 +164,8 @@ available. The latest build in this branch will be used.
You can install Bukkit plugins in two ways.
You can build spigot from source by adding `-e BUILD_SPIGOT_FROM_SOURCE=true`
### Using the /data volume
This is the easiest way if you are using a persistent `/data` mount.
@@ -266,6 +268,112 @@ downloaded, scaled, and converted from any other image format:
docker run -d -e ICON=http://..../some/image.png ...
### Rcon
To use rcon use the `ENABLE_RCON` and `RCON_PASSORD` variables.
By default rcon port will be `25575` but can easily be changed with the `RCON_PORT` variable.
docker run -d -e ENABLE_RCON=true -e RCON_PASSWORD=testing
### Query
Enabling this will enable the gamespy query protocol.
By default the query port will be `25565` (UDP) but can easily be changed with the `QUERY_PORT` variable.
docker run -d -e ENABLE_QUERY=true
### Max players
By default max players is 20, you can increase this with the `MAX_PLAYERS` variable.
docker run -d -e MAX_PLAYERS=50
### Max world size
This sets the maximum possible size in blocks, expressed as a radius, that the world border can obtain.
docker run -d -e MAX_WORLD_SIZE=10000
### Allow Nether
Allows players to travel to the Nether.
docker run -d -e ALLOW_NETHER=true
### Announce Player Achievements
Allows server to announce when a player gets an achievement.
docker run -d -e ANNOUNCE_PLAYER_ACHIEVEMENTS=true
### Enable Command Block
Enables command blocks
docker run -d -e ENABLE_COMMAND_BLOCK=true
### Force Gamemode
Force players to join in the default game mode.
- false - Players will join in the gamemode they left in.
- true - Players will always join in the default gamemode.
docker run -d -e FORCE_GAMEMODE=false
### Generate Structures
Defines whether structures (such as villages) will be generated.
- false - Structures will not be generated in new chunks.
- true - Structures will be generated in new chunks.
docker run -d -e GENERATE_STRUCTURES=true
### Hardcore
If set to true, players will be set to spectator mode if they die.
docker run -d -e HARDCORE=false
### Max Build Height
The maximum height in which building is allowed.
Terrain may still naturally generate above a low height limit.
docker run -d -e MAX_BUILD_HEIGHT=256
### Max Tick Time
The maximum number of milliseconds a single tick may take before the server watchdog stops the server with the message, A single server tick took 60.00 seconds (should be max 0.05); Considering it to be crashed, server will forcibly shutdown. Once this criteria is met, it calls System.exit(1).
Setting this to -1 will disable watchdog entirely
docker run -d -e MAX_TICK_TIME=60000
### Spawn Animals
Determines if animals will be able to spawn.
docker run -d -e SPAWN_ANIMALS=true
### Spawn Monsters
Determines if monsters will be spawned.
docker run -d -e SPAWN_MONSTERS=true
### Spawn NPCs
Determines if villagers will be spawned.
docker run -d -e SPAWN_NPCS=true
### View Distance
Sets the amount of world data the server sends the client, measured in chunks in each direction of the player (radius, not diameter).
It determines the server-side viewing distance.
docker run -d -e VIEW_DISTANCE=10
### Level Seed
If you want to create the Minecraft level with a specific seed, use `SEED`, such as

View File

@@ -5,11 +5,14 @@ enable-query=false
allow-flight=false
announce-player-achievements=true
server-port=25565
rcon.port=25575
query.port=25565
level-type=DEFAULT
enable-rcon=false
force-gamemode=false
level-seed=
server-ip=
max-tick-time=60000
max-build-height=256
spawn-npcs=true
white-list=false
@@ -31,3 +34,5 @@ view-distance=10
spawn-protection=16
motd=A Minecraft Server powered by Docker
generator-settings=
rcon.password=
max-world-size=29999984

View File

@@ -1,6 +1,7 @@
#!/bin/bash
umask 002
#umask 002
export HOME=/data
if [ ! -e /data/eula.txt ]; then
if [ "$EULA" != "" ]; then
@@ -39,35 +40,62 @@ echo "Checking type information."
case "$TYPE" in
*BUKKIT|*bukkit|SPIGOT|spigot)
TYPE=SPIGOT
case "$TYPE" in
*BUKKIT|*bukkit)
echo "Downloading latest CraftBukkit $VANILLA_VERSION server ..."
SERVER=craftbukkit_server.jar
;;
*)
echo "Downloading latest Spigot $VANILLA_VERSION server ..."
SERVER=spigot_server.jar
;;
esac
case $VANILLA_VERSION in
1.8*)
URL=/spigot18/$SERVER
;;
1.9*)
URL=/spigot19/$SERVER
;;
*)
echo "That version of $SERVER is not available."
exit 1
;;
esac
#attempt https, and if it fails, fallback to http and download that way. Display error if neither works.
wget -q -N $SERVER https://getspigot.org$URL || \
(echo "Falling back to http, unable to contact server using https..." && \
wget -q -N $SERVER http://getspigot.org$URL) || \
echo "Unable to download new copy of spigot server"
if [ -z "$BUILD_SPIGOT_FROM_SOURCE" ]; then
case "$TYPE" in
*BUKKIT|*bukkit)
echo "Downloading latest CraftBukkit $VANILLA_VERSION server ..."
SERVER=craftbukkit_server.jar
;;
*)
echo "Downloading latest Spigot $VANILLA_VERSION server ..."
SERVER=spigot_server.jar
;;
esac
case $VANILLA_VERSION in
1.8*)
URL=/spigot18/$SERVER
;;
1.9*)
URL=/spigot19/$SERVER
;;
*)
echo "That version of $SERVER is not available."
exit 1
;;
esac
#attempt https, and if it fails, fallback to http and download that way. Display error if neither works.
wget -q -N $SERVER https://getspigot.org$URL || \
(echo "Falling back to http, unable to contact server using https..." && \
wget -q -N $SERVER http://getspigot.org$URL) || \
echo "Unable to download new copy of spigot server"
fi
if [ "$BUILD_SPIGOT_FROM_SOURCE" = true ]; then
echo "Building spigot from source, might take a while, get some coffee"
if [ ! -f /data/spigot_server.jar ]; then
echo "Downloading and building buildtools for version $VANILLA_VERSION"
mkdir /data/temp
cd /data/temp
wget -P /data/temp https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar && \
java -jar /data/temp/BuildTools.jar --rev $VANILLA_VERSION && \
find * -maxdepth 0 ! -name '*.jar' -exec rm -rf {} \; && \
chown minecraft:minecraft spigot-*.jar && \
chown minecraft:minecraft craftbukkit-*.jar && \
mv spigot-*.jar /data/spigot_server.jar && \
mv craftbukkit-*.jar /data/craftbukkit_server.jar
echo "Cleaning up"
rm -rf /data/temp
cd /data
fi
case "$TYPE" in
*BUKKIT|*bukkit)
SERVER=craftbukkit_server.jar
;;
*)
SERVER=spigot_server.jar
;;
esac
fi
;;
FORGE|forge)
@@ -122,6 +150,11 @@ case "$TYPE" in
esac
#Switch to minecraft user
echo "...switching to user 'minecraft'"
su - minecraft
# If supplied with a URL for a world, download it and unpack
if [[ "$WORLD" ]]; then
case "X$WORLD" in
@@ -178,31 +211,135 @@ esac
fi
if [ ! -e server.properties ]; then
echo "Creating server.properties"
cp /tmp/server.properties .
if [ -n "$WHITELIST" ]; then
echo "Creating whitelist"
sed -i "/whitelist\s*=/ c whitelist=true" /data/server.properties
sed -i "/white-list\s*=/ c white-list=true" /data/server.properties
fi
if [ -n "$MOTD" ]; then
echo "Setting motd"
sed -i "/motd\s*=/ c motd=$MOTD" /data/server.properties
fi
if [ -n "$ALLOW_NETHER" ]; then
echo "Setting allow-nether"
sed -i "/allow-nether\s*=/ c allow-nether=$ALLOW_NETHER" /data/server.properties
fi
if [ -n "$ANNOUNCE_PLAYER_ACHIEVEMENTS" ]; then
echo "Setting announce-player-achievements"
sed -i "/announce-player-achievements\s*=/ c announce-player-achievements=$ANNOUNCE_PLAYER_ACHIEVEMENTS" /data/server.properties
fi
if [ -n "$ENABLE_COMMAND_BLOCK" ]; then
echo "Setting enable-command-block"
sed -i "/enable-command-block\s*=/ c enable-command-block=$ENABLE_COMMAND_BLOCK" /data/server.properties
fi
if [ -n "$SPAWN_ANIMAILS" ]; then
echo "Setting spawn-animals"
sed -i "/spawn-animals\s*=/ c spawn-animals=$SPAWN_ANIMAILS" /data/server.properties
fi
if [ -n "$SPAWN_MONSTERS" ]; then
echo "Setting spawn-monsters"
sed -i "/spawn-monsters\s*=/ c spawn-monsters=$SPAWN_MONSTERS" /data/server.properties
fi
if [ -n "$SPAWN_NPCS" ]; then
echo "Setting spawn-npcs"
sed -i "/spawn-npcs\s*=/ c spawn-npcs=$SPAWN_NPCS" /data/server.properties
fi
if [ -n "$GENERATE_STRUCTURES" ]; then
echo "Setting generate-structures"
sed -i "/generate-structures\s*=/ c generate-structures=$GENERATE_STRUCTURES" /data/server.properties
fi
if [ -n "$VIEW_DISTANCE" ]; then
echo "Setting view-distance"
sed -i "/view-distance\s*=/ c view-distance=$VIEW_DISTANCE" /data/server.properties
fi
if [ -n "$HARDCORE" ]; then
echo "Setting hardcore"
sed -i "/hardcore\s*=/ c hardcore=$HARDCORE" /data/server.properties
fi
if [ -n "$MAX_BUILD_HEIGHT" ]; then
echo "Setting max-build-height"
sed -i "/max-build-height\s*=/ c max-build-height=$MAX_BUILD_HEIGHT" /data/server.properties
fi
if [ -n "$FORCE_GAMEMODE" ]; then
echo "Setting force-gamemode"
sed -i "/force-gamemode\s*=/ c force-gamemode=$FORCE_GAMEMODE" /data/server.properties
fi
if [ -n "$MAX_TICK_TIME" ]; then
echo "Setting max-tick-time"
sed -i "/max-tick-time\s*=/ c max-tick-time=$MAX_TICK_TIME" /data/server.properties
fi
if [ -n "$ENABLE_QUERY" ]; then
echo "Enabling query"
sed -i "/enable-query\s*=/ c enable-query=$ENABLE_QUERY" /data/server.properties
fi
if [ -n "$QUERY_PORT" ]; then
echo "Setting query port"
sed -i "/query.port\s*=/ c query.port=$QUERY_PORT" /data/server.properties
fi
if [ -n "$ENABLE_RCON" ]; then
echo "Enabling rcon"
sed -i "/enable-rcon\s*=/ c enable-rcon=$ENABLE_RCON" /data/server.properties
fi
if [ -n "$RCON_PASSWORD" ]; then
echo "Setting rcon password to $RCON_PASSWORD"
sed -i "/rcon.password\s*=/ c rcon.password=$RCON_PASSWORD" /data/server.properties
fi
if [ -n "$RCON_PORT" ]; then
echo "Setting rcon port"
sed -i "/rcon.port\s*=/ c rcon.port=$RCON_PORT" /data/server.properties
fi
if [ -n "$MAX_PLAYERS" ]; then
echo "Setting max players"
sed -i "/max-players\s*=/ c max-players=$MAX_PLAYERS" /data/server.properties
fi
if [ -n "$MAX_WORLD_SIZE" ]; then
echo "Setting max world size"
sed -i "/max-world-size\s*=/ c max-world-size=$MAX_WORLD_SIZE" /data/server.properties
fi
if [ -n "$LEVEL" ]; then
echo "Setting level name"
sed -i "/level-name\s*=/ c level-name=$LEVEL" /data/server.properties
fi
if [ -n "$SEED" ]; then
echo "Setting seed"
sed -i "/level-seed\s*=/ c level-seed=$SEED" /data/server.properties
fi
if [ -n "$PVP" ]; then
echo "Setting PVP"
sed -i "/pvp\s*=/ c pvp=$PVP" /data/server.properties
fi
if [ -n "$LEVEL_TYPE" ]; then
# normalize to uppercase
echo "Setting level type"
LEVEL_TYPE=${LEVEL_TYPE^^}
# check for valid values and only then set
case $LEVEL_TYPE in
@@ -217,10 +354,12 @@ if [ ! -e server.properties ]; then
fi
if [ -n "$GENERATOR_SETTINGS" ]; then
echo "Setting generator settings"
sed -i "/generator-settings\s*=/ c generator-settings=$GENERATOR_SETTINGS" /data/server.properties
fi
if [ -n "$DIFFICULTY" ]; then
echo "Setting difficulty"
case $DIFFICULTY in
peaceful|0)
DIFFICULTY=0
@@ -243,6 +382,7 @@ if [ ! -e server.properties ]; then
fi
if [ -n "$MODE" ]; then
echo "Setting mode"
case ${MODE,,?} in
0|1|2|3)
;;
@@ -270,10 +410,12 @@ fi
if [ -n "$OPS" -a ! -e ops.txt.converted ]; then
echo "Setting ops"
echo $OPS | awk -v RS=, '{print}' >> ops.txt
fi
if [ -n "$WHITELIST" -a ! -e white-list.txt.converted ]; then
echo "Setting whitelist"
echo $WHITELIST | awk -v RS=, '{print}' >> white-list.txt
fi

View File

@@ -11,5 +11,4 @@ while lsof -- /start-minecraft; do
echo -n "."
sleep 1
done
echo "...switching to user 'minecraft'"
exec sudo -E -u minecraft /start-minecraft
exec /start-minecraft