2020-12-31 11:46:00 +01:00
|
|
|
# Copyright (C) 2020 Jef Roosens
|
|
|
|
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
2020-12-30 14:02:22 +01:00
|
|
|
FROM openjdk:8-slim
|
|
|
|
|
|
|
|
# Build arguments
|
|
|
|
ARG MC_VERSION
|
|
|
|
ARG FORGE_VERSION
|
|
|
|
|
|
|
|
# Create worlds and config directory
|
|
|
|
WORKDIR /mc
|
|
|
|
RUN mkdir worlds config
|
|
|
|
|
|
|
|
# Download installer jar
|
|
|
|
ADD "https://files.minecraftforge.net/maven/net/minecraftforge/forge/${MC_VERSION}-${FORGE_VERSION}/forge-${MC_VERSION}-${FORGE_VERSION}-installer.jar" installer.jar
|
|
|
|
|
2020-12-30 15:57:45 +01:00
|
|
|
# Install forge & remove installer
|
2020-12-30 14:02:22 +01:00
|
|
|
RUN java -jar installer.jar server --installServer && \
|
|
|
|
rm installer.jar installer.jar.log
|
|
|
|
|
2020-12-30 15:57:45 +01:00
|
|
|
# Forge doesn't use one single name, so this is needed to know the name of the executable
|
|
|
|
ENV FORGE_JAR="forge-${MC_VERSION}-${FORGE_VERSION}.jar"
|
|
|
|
|
2020-12-30 14:02:22 +01:00
|
|
|
# Store the cache in an anonymous volume, which means it won't get stored in the other volumes
|
|
|
|
VOLUME /mc/config/cache
|
|
|
|
|
|
|
|
WORKDIR /mc/config
|
|
|
|
|
|
|
|
# Default value to keep users from eating up all ram accidentally
|
|
|
|
ENV XMS=4
|
|
|
|
|
|
|
|
# We copy over the server jar(s) as well to make the backup more reproducible to deploy
|
|
|
|
ENTRYPOINT mv -n /mc/*.jar /mc/*.json /mc/libraries /mc/config && \
|
|
|
|
echo "eula=true" > /mc/config/eula.txt && \
|
|
|
|
java \
|
|
|
|
-Xms"${XMS}G" \
|
|
|
|
-Xmx"${XMX:-$XMS}G" \
|
|
|
|
-XX:+UseG1GC \
|
|
|
|
-XX:+ParallelRefProcEnabled \
|
|
|
|
-XX:MaxGCPauseMillis=200 \
|
|
|
|
-XX:+UnlockExperimentalVMOptions \
|
|
|
|
-XX:+DisableExplicitGC \
|
|
|
|
-XX:+AlwaysPreTouch \
|
|
|
|
-XX:G1NewSizePercent="$([ $XMS -gt 12 ] && echo 40 || echo 30)" \
|
|
|
|
-XX:G1MaxNewSizePercent="$([ $XMS -gt 12 ] && echo 50 || echo 40)" \
|
|
|
|
-XX:G1HeapRegionSize="$([ $XMS -gt 12 ] && echo 16 || echo 8)"M \
|
|
|
|
-XX:G1ReservePercent="$([ $XMS -gt 12 ] && echo 15 || echo 20)" \
|
|
|
|
-XX:G1HeapWastePercent=5 \
|
|
|
|
-XX:G1MixedGCCountTarget=4 \
|
|
|
|
-XX:InitiatingHeapOccupancyPercent="$([ $XMS -gt 12 ] && echo 20 || echo 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 \
|
2020-12-30 15:57:45 +01:00
|
|
|
-jar "$FORGE_JAR" \
|
2020-12-30 14:02:22 +01:00
|
|
|
--universe /mc/worlds \
|
|
|
|
--nogui
|