FROM openjdk:8-jre-alpine

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

# This allows me to talk to Minecraft server
ADD ./rcon-cli_linux_amd64 /usr/local/bin/rcon-cli

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

## rm -rf /root/.cache

ADD launch.sh /launch.sh

# && 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 ["/launch-minecraft.sh"]
CMD ["/launch.sh"]

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


