Skip to content
Snippets Groups Projects
Dockerfile 3.61 KiB
Newer Older
Jakob Moser's avatar
Jakob Moser committed
# Base image on OpenJDK 11 JRE
FROM openjdk:16.0.1-slim
TheBroTMv2's avatar
TheBroTMv2 committed
LABEL org.label-schema.name="clspigot-docker" \
      org.label-schema.description="Docker Container for an Papermc Server" \
      org.label-schema.vcs-url="https://gitlab.cl.uni-heidelberg.de/tmueller/clspigot-docker/" \
      maintainer="mueller@tobistech.ovh" \
      org.label-schema.schema-version=1.0
Jakob Moser's avatar
Jakob Moser committed

# Execute all the following instructions in the container as user "root"
tmueller's avatar
tmueller committed
USER root
Jakob Moser's avatar
Jakob Moser committed
# User and group used to run the PaperMC server (build time argument, defaulting to "papermc")
ARG papermc_user=papermc
ARG papermc_group=papermc
ARG vcsref=""
Jakob Moser's avatar
Jakob Moser committed

LABEL org.label-schema.vcs-ref=${vcsref}
TheBroTMv2's avatar
TheBroTMv2 committed
WORKDIR /

Jakob Moser's avatar
Jakob Moser committed
# Default environment variables
# The Java Options are Aikar's flags to optimize a few things, among them garbage collection:
# https://aikar.co/2018/07/02/tuning-the-jvm-g1gc-garbage-collector-flags-for-minecraft/
tmueller's avatar
tmueller committed
ENV MC_VERSION="latest" \
    PAPER_BUILD="latest" \
tmueller's avatar
tmueller committed
    MC_RAM="2G" \
Jakob Moser's avatar
Jakob Moser committed
    JAVA_OPTS="-XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true" \
#Man kann nun auch die guid des eigenen benutzers passen und mus somit nichtmehr die rechte des hostsystems anpassen, bitte die GUID eines non-root users nehmen der an dem speicherort zugriff hat.
tmueller's avatar
tmueller committed
    GUID=1000 \
TheBroTMv2's avatar
TheBroTMv2 committed
    TZ=Europe/Berlin \
TheBroTMv2's avatar
TheBroTMv2 committed
    TM_BASE_AUTH="username:supercooles_passwort_hier_einfuegen" \
    TM_BASE_URL=""
# Copy over the three script files (entrypoint, backup, restore, helath, test(optional) and crontab
COPY papermc.sh backup.sh restore.sh health.sh test.sh /
COPY crontab /etc/cron.d/backup

Jakob Moser's avatar
Jakob Moser committed
# Set Timezone
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

TheBroTMv2's avatar
TheBroTMv2 committed
# Create /papermc and /backup directories and /web for the dynmap
RUN mkdir /papermc /backup /web
#sets permission for the cronjobs
RUN chmod 0644 /etc/cron.d/backup
TheBroTMv2's avatar
TheBroTMv2 committed
#starts the service for cron
TheBroTMv2's avatar
TheBroTMv2 committed

# Add papermc user and group, then change ownership of /papermc and /backup to this user
TheBroTMv2's avatar
TheBroTMv2 committed
RUN groupadd -g ${GUID} ${papermc_group} 
RUN useradd -g ${GUID} -l -M -s /bin/false -u ${GUID} ${papermc_user} 
TheBroTMv2's avatar
TheBroTMv2 committed
RUN chown -R ${GUID} /papermc /backup /web
Jakob Moser's avatar
Jakob Moser committed

# Get package lists, install needed packages, then remove the package lists again (to save space)
# "webp" is needed to generate images with better compression for the dynamic map (optional, needs further configuration in dynmap-plugin´s config file)
# "cron" is for making it possible to restart the server every day, week or soemthing similar (its optional)
# "curl" is required for getting the server initialised
# "screen" is required for getting the server running at all
RUN apt-get update && apt-get install -y \
    cron \
    curl \
    jq \
    screen \
    webp \
TheBroTMv2's avatar
TheBroTMv2 committed
    nano \
TheBroTMv2's avatar
TheBroTMv2 committed
    && rm -rf /var/lib/apt/lists/* \
    service cron start
Jakob Moser's avatar
Jakob Moser committed
# Execute all following commands as the papermc user
USER $papermc_user

# Start script and also entrypoint for the container
CMD ["sh", "/papermc.sh"]

#Alle 10s testen ob exit code = 0
HEALTHCHECK --interval=10s --timeout=10s --start-period=30s \ 
    CMD ["sh", "/health.sh"]

# Container setup, specifies needed ports. May be adjusted or overwritten if plugins need other ports
tmueller's avatar
tmueller committed
EXPOSE 25565/tcp
Jakob Moser's avatar
Jakob Moser committed
#Specifies the datastructure in the container
tmueller's avatar
tmueller committed
VOLUME /papermc
TheBroTMv2's avatar
TheBroTMv2 committed
VOLUME /web