FROM openjdk:8-jre-alpine

ADD launch.sh /launch-minecraft.sh
# ADD MCRcon/demo.py /demo.py
# ADD MCRcon/mcrcon.py /mcrcon.py

WORKDIR /home/minecraft
# ADD launch.sh /home/minecraft/launch.sh
# ADD start-minecraft.sh /home/minecraft/start-minecraft.sh
# ADD base.properties /home/minecraft/base.properties
# ADD https://github.com/itzg/rcon-cli/releases/download/1.3/rcon-cli_linux_amd64 /usr/local/bin/rcon-cli

# Ok, but I can do better with some python scripts.  :D
# ADD ./rcon-cli_linux_amd64 /usr/local/bin/rcon-cli

RUN apk add --no-cache su-exec python python-dev py2-pip tini bash \
&& addgroup -g 1000 minecraft \
&& adduser -D -u 1000 -G minecraft -h /home/minecraft minecraft \
&& pip install mcstatus \
&& apk del python-dev \
&& rm -rf /var/cache/apk/* 

# && chown minecraft:minecraft /home/minecraft/*

# Oddly, mcstatus localhost ping fails/unable to resolve hostname.  

HEALTHCHECK CMD mcstatus 127.0.0.1 ping

EXPOSE 25565 25575

VOLUME ["/home/minecraft"]
ENTRYPOINT [ "tini", "--" ]
# CMD ["/home/minecraft/launch.sh"]
CMD ["/launch-minecraft.sh"]

ENV UID=1000 GIU=1000 \
  SERVER=server.jar \
  JVM_XX_OPTS="-XX:+UseG1GC" MEMORY="1G" 


