minecraft/Dockerfile

25 lines
768 B
Docker

FROM openjdk:12-jdk-alpine as builder
# Run in /tmp
WORKDIR /tmp
RUN apk add --no-cache --update curl git
RUN curl -sS https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar > BuildTools.jar
# Build executable
RUN java -Xmx2048M -jar BuildTools.jar --rev latest
# Preparing runtime container with slimmed-down version of openjdk
FROM openjdk:12-alpine
EXPOSE 25565
VOLUME /worlds
WORKDIR /minecraft
RUN chown nobody:nogroup /minecraft
USER nobody:nogroup
ENTRYPOINT ["java"]
CMD ["-Xmx2048M", "-Xms1024M", "-Dfile.encoding=UTF-8", "-Dcom.mojang.eula.agree=true", "-jar", "/minecraft/server.jar", "--world-dir", "/worlds"]
# Copy built executable
COPY --chown=nobody:nogroup --from=builder /tmp/spigot-*.jar server.jar