This commit is contained in:
Roger 2024-11-24 14:29:20 -05:00
parent aa21c24051
commit 7fb9a38398
2 changed files with 67 additions and 0 deletions

20
Dockerfile Normal file
View file

@ -0,0 +1,20 @@
# syntax=docker/dockerfile:1
FROM openjdk:21-buster
LABEL version="1.23.0"
RUN apt-get update && apt-get install -y curl unzip && \
adduser --uid 99 --gid 100 --home /data --disabled-password minecraft
COPY launch.sh /launch.sh
RUN chmod +x /launch.sh
USER minecraft
VOLUME /data
WORKDIR /data
EXPOSE 25565/tcp
CMD ["/launch.sh"]

47
launch.sh Normal file
View file

@ -0,0 +1,47 @@
#!/bin/bash
set -x
NEOFORGE_VERSION=21.1.80
cd /data
if ! [[ "$EULA" = "false" ]]; then
echo "eula=true" > eula.txt
else
echo "You must accept the EULA to install."
exit 99
fi
if ! [[ -f 'Server-Files-1.23.0.zip' ]]; then
rm -fr config defaultconfigs kubejs mods packmenu Simple.zip forge*
curl -Lo 'Server-Files-1.23.0.zip' 'https://edge.forgecdn.net/files/5929/640/Server-Files-1.23.zip' || exit 9
unzip -u -o 'Server-Files-1.23.0.zip' -d /data
DIR_TEST=$(find . -type d -maxdepth 1 | tail -1 | sed 's/^.\{2\}//g')
if [[ $(find . -type d -maxdepth 1 | wc -l) -gt 1 ]]; then
cd "${DIR_TEST}"
mv -f * /data
cd /data
rm -fr "$DIR_TEST"
fi
curl -Lo neoforge-${NEOFORGE_VERSION}-installer.jar http://files.neoforged.net/maven/net/neoforged/neoforge/$NEOFORGE_VERSION/neoforge-$NEOFORGE_VERSION-installer.jar
java -jar neoforge-${NEOFORGE_VERSION}-installer.jar --installServer
fi
if [[ -n "$JVM_OPTS" ]]; then
sed -i '/-Xm[s,x]/d' user_jvm_args.txt
for j in ${JVM_OPTS}; do sed -i '$a\'$j'' user_jvm_args.txt; done
fi
if [[ -n "$MOTD" ]]; then
sed -i "s/motd\s*=/ c motd=$MOTD" /data/server.properties
fi
if [[ -n "$OPS" ]]; then
echo $OPS | awk -v RS=, '{print}' > ops.txt
fi
if [[ -n "$ALLOWLIST" ]]; then
echo $ALLOWLIST | awk -v RS=, '{print}' > white-list.txt
fi
sed -i 's/server-port.*/server-port=25565/g' server.properties
chmod 755 run.sh
./run.sh