Merge pull request #115 from ikke-t/alpine

Switch to Alpine linux for container base
This commit is contained in:
Geoff Bourne 2017-02-22 13:23:06 -06:00 committed by GitHub
commit 6157a693f1
3 changed files with 29 additions and 26 deletions

View file

@ -1,30 +1,32 @@
FROM openjdk:8-jre
FROM 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
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_amd64 /usr/local/bin/restify
ADD https://github.com/itzg/restify/releases/download/1.0.4/restify_linux_amd64 /usr/local/bin/restify
COPY start.sh /start
COPY start-minecraft.sh /start-minecraft
COPY mcadmin.jq /usr/share

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"
@ -363,7 +363,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
@ -402,7 +402,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 $@