This repository has been archived on 2021-12-24. You can view files and clone it, but cannot push or open issues/pull-requests.
self-hosting/minecraft/fabric/Dockerfile

45 lines
1.3 KiB
Docker
Raw Normal View History

ARG BASE_IMAGE
# We use ${:-} instead of a default value because the argument is always passed
# to the build, it'll just be blank most likely
FROM ${BASE_IMAGE:-'openjdk:8-jre-slim'}
2020-12-30 12:24:21 +01:00
2020-12-30 12:53:37 +01:00
# Build arguments
2021-01-26 14:05:59 +01:00
ARG MC_VERSION
2020-12-30 12:53:37 +01:00
ARG FABRIC_VERSION
2020-12-30 12:24:21 +01:00
2021-01-26 14:05:59 +01:00
# Install mcstatus for healthchecks
RUN apt update && \
apt install --no-install-recommends -y python3-minimal python3-setuptools python3-pip && \
python3 -m pip install mcstatus && \
apt --purge remove -y python3-pip python3-setuptools && \
apt clean
2020-12-30 12:53:37 +01:00
# Create worlds and config directory
2021-01-26 14:05:59 +01:00
WORKDIR /app
2020-12-30 12:53:37 +01:00
RUN mkdir worlds config
2020-12-30 12:24:21 +01:00
# Download installer jar
2020-12-30 14:02:22 +01:00
ADD "https://maven.fabricmc.net/net/fabricmc/fabric-installer/$FABRIC_VERSION/fabric-installer-$FABRIC_VERSION.jar" installer.jar
2020-12-30 12:24:21 +01:00
2020-12-30 14:02:22 +01:00
# Install fabric & remove installer
2021-01-26 14:05:59 +01:00
RUN java -jar installer.jar server -downloadMinecraft -mcversion "$MC_VERSION" && \
rm installer.jar
2020-12-30 12:24:21 +01:00
# Store the cache in an anonymous volume, which means it won't get stored in the other volumes
2021-01-26 14:05:59 +01:00
VOLUME /app/config/cache
2020-12-30 12:24:21 +01:00
2020-12-30 12:53:37 +01:00
2020-12-30 12:24:21 +01:00
# Default value to keep users from eating up all ram accidentally
2021-01-26 14:05:59 +01:00
ENV XMX=4
ENV MC_VERSION="${MC_VERSION}"
ENV FABRIC_VERSION="${FABRIC_VERSION}"
# Entrypoint runs in /app/config
COPY entrypoint.sh /entrypoint.sh
WORKDIR /app/config
ENTRYPOINT /entrypoint.sh
2020-12-30 12:24:21 +01:00
2021-01-26 14:05:59 +01:00
HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \
CMD mcstatus localhost:25565 ping