From fa44bd7b0cc569a13c763273fe97bd8608cdbf3d Mon Sep 17 00:00:00 2001 From: Chewing_Bever Date: Wed, 30 Dec 2020 14:02:22 +0100 Subject: [PATCH] Added forge server configs --- .gitignore | 1 + fabric/Dockerfile | 8 +++--- forge/.env.example | 2 ++ forge/Dockerfile | 55 ++++++++++++++++++++++++++++++++++++++++ forge/docker-compose.yml | 23 +++++++++++++++++ 5 files changed, 85 insertions(+), 4 deletions(-) create mode 100644 .gitignore create mode 100644 forge/.env.example create mode 100644 forge/Dockerfile create mode 100644 forge/docker-compose.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4c49bd7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.env diff --git a/fabric/Dockerfile b/fabric/Dockerfile index ef609f9..31e0e97 100644 --- a/fabric/Dockerfile +++ b/fabric/Dockerfile @@ -8,11 +8,11 @@ WORKDIR /mc RUN mkdir worlds config # Download installer jar -ADD "https://maven.fabricmc.net/net/fabricmc/fabric-installer/$FABRIC_VERSION/fabric-installer-$FABRIC_VERSION.jar" fabric-installer.jar +ADD "https://maven.fabricmc.net/net/fabricmc/fabric-installer/$FABRIC_VERSION/fabric-installer-$FABRIC_VERSION.jar" installer.jar -# Install fabric, sign eula & remove installer -RUN java -jar fabric-installer.jar server -downloadMinecraft && \ -rm fabric-installer.jar +# Install fabric & remove installer +RUN java -jar installer.jar server -downloadMinecraft && \ +rm installer.jar # Store the cache in an anonymous volume, which means it won't get stored in the other volumes VOLUME /mc/config/cache diff --git a/forge/.env.example b/forge/.env.example new file mode 100644 index 0000000..3a4e4fc --- /dev/null +++ b/forge/.env.example @@ -0,0 +1,2 @@ +MC_VERSION= +FORGE_VERSION= diff --git a/forge/Dockerfile b/forge/Dockerfile new file mode 100644 index 0000000..733d02c --- /dev/null +++ b/forge/Dockerfile @@ -0,0 +1,55 @@ +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 + +# Install forge, rename forge jar & remove installer +RUN java -jar installer.jar server --installServer && \ +mv forge-${MC_VERSION}-${FORGE_VERSION}.jar forge.jar && \ +rm installer.jar installer.jar.log + +# 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 \ +-jar forge.jar \ +--universe /mc/worlds \ +--nogui diff --git a/forge/docker-compose.yml b/forge/docker-compose.yml new file mode 100644 index 0000000..a6c7555 --- /dev/null +++ b/forge/docker-compose.yml @@ -0,0 +1,23 @@ +version: '3.5' +services: + forge: + build: + context: . + args: + - 'MC_VERSION=${MC_VERSION}' + - 'FORGE_VERSION=${FORGE_VERSION}' + image: 'mc-forge-server:${MC_VERSION}-${FORGE_VERSION}' + + restart: 'unless-stopped' + stdin_open: true + tty: true + + environment: + - XMS=4 + - XMX=4 + ports: + - '25565:25565' + volumes: + - '/data/mc/forge/config:/mc/config' + - '/data/mc/forge/mods:/mc/config/mods' + - '/data/mc/forge/worlds:/mc/worlds'