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
ENV APT_GET_UPDATE 2016-04-23
RUN apt-get update
RUN echo "http://dl-3.alpinelinux.org/alpine/v3.5/community/" >> /etc/apk/repositories &&\
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 \
imagemagick \
lsof \
nano \
sudo \
vim \
jq \
&& apt-get clean
#nano \
#sudo \
#vim \
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 /config \
&& mkdir /mods \
&& mkdir /plugins \
&& mkdir /home/minecraft \
&& chown minecraft:minecraft /data /config /mods /plugins /home/minecraft
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
COPY start.sh /start
COPY start-minecraft.sh /start-minecraft
@ -38,6 +45,6 @@ ENTRYPOINT [ "/start" ]
ENV UID=1000 GID=1000 \
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 \
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."
case "X$VERSION" in
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)
VANILLA_VERSION=`curl -sSL $VERSIONS_JSON | jq -r '.latest.snapshot'`
VANILLA_VERSION=`wget -O - -q $VERSIONS_JSON | jq -r '.latest.snapshot'`
;;
X[1-9]*)
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
@ -120,7 +120,7 @@ function installForge {
echo "Checking Forge version information."
case $FORGEVERSION in
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\"]")
if [ $FORGE_VERSION = null ]; then
FORGE_VERSION=$(cat /tmp/forge.json | jq -r ".promos[\"$norm-latest\"]")
@ -138,7 +138,7 @@ function installForge {
esac
# 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 $FORGEVERSION >= 10.13.2.1300
normForgeVersion="$norm-$FORGE_VERSION-$norm"
@ -320,7 +320,7 @@ if [ ! -e server.properties ]; then
if [ -n "$LEVEL_TYPE" ]; then
# normalize to uppercase
LEVEL_TYPE=${LEVEL_TYPE^^}
LEVEL_TYPE=$( echo ${LEVEL_TYPE} | tr '[:lower:]' '[:upper:]' )
echo "Setting level type to $LEVEL_TYPE"
# check for valid values and only then set
case $LEVEL_TYPE in
@ -359,7 +359,8 @@ if [ ! -e server.properties ]; then
if [ -n "$MODE" ]; then
echo "Setting mode"
case ${MODE,,?} in
MODE_LC=$( echo $MODE | tr '[:upper:]' '[:lower:]' )
case $MODE_LC in
0|1|2|3)
;;
su*)

View File

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