changed to work on alpine container

This commit is contained in:
Ilkka Tengvall 2016-12-07 00:31:06 +02:00
parent 0cb0755739
commit 08d459c373
3 changed files with 33 additions and 25 deletions

View File

@ -1,29 +1,36 @@
FROM java:8 FROM alpine
#FROM container4armhf/armhf-alpine
MAINTAINER itzg MAINTAINER itzg
ENV APT_GET_UPDATE 2016-04-23 RUN echo "http://dl-3.alpinelinux.org/alpine/v3.5/community/" >> /etc/apk/repositories &&\
RUN apt-get update apk update && \
apk add \
openjdk8-jre-base \
openssl \
imagemagick \
lsof \
su-exec \
bash \
git \
jq &&\
rm -rf /var/cache/apk/*
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y \ #nano \
imagemagick \ #sudo \
lsof \ #vim \
nano \
sudo \
vim \
jq \
&& apt-get clean
RUN useradd -s /bin/false --uid 1000 minecraft \ RUN addgroup -g 1000 minecraft \
&& adduser -Ss /bin/false -u 1000 -G minecraft -h /home/minecraft minecraft \
&& mkdir /data \ && mkdir /data \
&& mkdir /config \ && mkdir /config \
&& mkdir /mods \ && mkdir /mods \
&& mkdir /plugins \ && mkdir /plugins \
&& mkdir /home/minecraft \
&& chown minecraft:minecraft /data /config /mods /plugins /home/minecraft && chown minecraft:minecraft /data /config /mods /plugins /home/minecraft
EXPOSE 25565 25575 EXPOSE 25565 25575
#ADD https://github.com/itzg/restify/releases/download/1.0.3/restify_linux_arm /usr/local/bin/restify
ADD https://github.com/itzg/restify/releases/download/1.0.3/restify_linux_amd64 /usr/local/bin/restify ADD https://github.com/itzg/restify/releases/download/1.0.3/restify_linux_amd64 /usr/local/bin/restify
COPY start.sh /start COPY start.sh /start
COPY start-minecraft.sh /start-minecraft COPY start-minecraft.sh /start-minecraft
@ -38,6 +45,6 @@ ENTRYPOINT [ "/start" ]
ENV UID=1000 GID=1000 \ ENV UID=1000 GID=1000 \
MOTD="A Minecraft Server Powered by Docker" \ MOTD="A Minecraft Server Powered by Docker" \
JVM_OPTS="-Xmx1024M -Xms1024M" \ JVM_OPTS="-Xmx1024M -Xms256M" \
TYPE=VANILLA VERSION=LATEST FORGEVERSION=RECOMMENDED LEVEL=world PVP=true DIFFICULTY=easy \ TYPE=VANILLA VERSION=LATEST FORGEVERSION=RECOMMENDED LEVEL=world PVP=true DIFFICULTY=easy \
LEVEL_TYPE=DEFAULT GENERATOR_SETTINGS= WORLD= MODPACK= ONLINE_MODE=TRUE CONSOLE=true LEVEL_TYPE=DEFAULT GENERATOR_SETTINGS= WORLD= MODPACK= ONLINE_MODE=TRUE CONSOLE=true

View File

@ -23,16 +23,16 @@ VERSIONS_JSON=https://launchermeta.mojang.com/mc/game/version_manifest.json
echo "Checking version information." echo "Checking version information."
case "X$VERSION" in case "X$VERSION" in
X|XLATEST|Xlatest) X|XLATEST|Xlatest)
VANILLA_VERSION=`curl -sSL $VERSIONS_JSON | jq -r '.latest.release'` VANILLA_VERSION=`wget -O - -q $VERSIONS_JSON | jq -r '.latest.release'`
;; ;;
XSNAPSHOT|Xsnapshot) XSNAPSHOT|Xsnapshot)
VANILLA_VERSION=`curl -sSL $VERSIONS_JSON | jq -r '.latest.snapshot'` VANILLA_VERSION=`wget -O - -q $VERSIONS_JSON | jq -r '.latest.snapshot'`
;; ;;
X[1-9]*) X[1-9]*)
VANILLA_VERSION=$VERSION VANILLA_VERSION=$VERSION
;; ;;
*) *)
VANILLA_VERSION=`curl -sSL $VERSIONS_JSON | jq -r '.latest.release'` VANILLA_VERSION=`wget -O - -q $VERSIONS_JSON | jq -r '.latest.release'`
;; ;;
esac esac
@ -120,7 +120,7 @@ function installForge {
echo "Checking Forge version information." echo "Checking Forge version information."
case $FORGEVERSION in case $FORGEVERSION in
RECOMMENDED) RECOMMENDED)
curl -o /tmp/forge.json -sSL http://files.minecraftforge.net/maven/net/minecraftforge/forge/promotions_slim.json wget -q -O /tmp/forge.json -sSL http://files.minecraftforge.net/maven/net/minecraftforge/forge/promotions_slim.json
FORGE_VERSION=$(cat /tmp/forge.json | jq -r ".promos[\"$norm-recommended\"]") FORGE_VERSION=$(cat /tmp/forge.json | jq -r ".promos[\"$norm-recommended\"]")
if [ $FORGE_VERSION = null ]; then if [ $FORGE_VERSION = null ]; then
FORGE_VERSION=$(cat /tmp/forge.json | jq -r ".promos[\"$norm-latest\"]") FORGE_VERSION=$(cat /tmp/forge.json | jq -r ".promos[\"$norm-latest\"]")
@ -138,7 +138,7 @@ function installForge {
esac esac
# URL format changed for 1.7.10 from 10.13.2.1300 # 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) sorted=$( (echo $FORGE_VERSION; echo 10.13.2.1300) | sort -V | head -1)
if [[ $norm == '1.7.10' && $sorted == '10.13.2.1300' ]]; then if [[ $norm == '1.7.10' && $sorted == '10.13.2.1300' ]]; then
# if $FORGEVERSION >= 10.13.2.1300 # if $FORGEVERSION >= 10.13.2.1300
normForgeVersion="$norm-$FORGE_VERSION-$norm" normForgeVersion="$norm-$FORGE_VERSION-$norm"
@ -320,7 +320,7 @@ if [ ! -e server.properties ]; then
if [ -n "$LEVEL_TYPE" ]; then if [ -n "$LEVEL_TYPE" ]; then
# normalize to uppercase # normalize to uppercase
LEVEL_TYPE=${LEVEL_TYPE^^} LEVEL_TYPE=$( echo ${LEVEL_TYPE} | tr '[:lower:]' '[:upper:]' )
echo "Setting level type to $LEVEL_TYPE" echo "Setting level type to $LEVEL_TYPE"
# check for valid values and only then set # check for valid values and only then set
case $LEVEL_TYPE in case $LEVEL_TYPE in
@ -359,7 +359,8 @@ if [ ! -e server.properties ]; then
if [ -n "$MODE" ]; then if [ -n "$MODE" ]; then
echo "Setting mode" echo "Setting mode"
case ${MODE,,?} in MODE_LC=$( echo $MODE | tr '[:upper:]' '[:lower:]' )
case $MODE_LC in
0|1|2|3) 0|1|2|3)
;; ;;
su*) su*)

View File

@ -1,13 +1,13 @@
#!/bin/sh #!/bin/sh
set -e set -e
usermod --uid $UID minecraft sed -i "/^minecraft/s/1000/${UID}/g" /etc/passwd
groupmod --gid $GID minecraft sed -i "/^minecraft/s/1000/${GID}/g" /etc/group
if [ "$SKIP_OWNERSHIP_FIX" != "TRUE" ]; then if [ "$SKIP_OWNERSHIP_FIX" != "TRUE" ]; then
fix_ownership() { fix_ownership() {
dir=$1 dir=$1
if ! sudo -u minecraft test -w $dir; then if ! su-exec minecraft test -w $dir; then
echo "Correcting writability of $dir ..." echo "Correcting writability of $dir ..."
chown -R minecraft:minecraft $dir chown -R minecraft:minecraft $dir
chmod -R u+w $dir chmod -R u+w $dir
@ -19,4 +19,4 @@ if [ "$SKIP_OWNERSHIP_FIX" != "TRUE" ]; then
fi fi
echo "Switching to user 'minecraft'" echo "Switching to user 'minecraft'"
exec sudo -E -u minecraft /start-minecraft "$@" su-exec minecraft /start-minecraft $@