diff options
author | Botond Hende <nettingman@gmail.com> | 2024-04-22 23:29:38 +0200 |
---|---|---|
committer | Botond Hende <nettingman@gmail.com> | 2024-04-22 23:29:38 +0200 |
commit | 408ace2b1031b152baf55a01e490f227fa3b5437 (patch) | |
tree | 00e2cab7f43707c0f6920f5c4d5c82f14ae578cf |
initial commit
-rw-r--r-- | Dockerfile | 26 | ||||
-rw-r--r-- | Makefile | 110 | ||||
-rwxr-xr-x | papermc_getlatest.sh | 13 | ||||
-rw-r--r-- | start.sh | 3 |
4 files changed, 152 insertions, 0 deletions
diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4debfb6 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +FROM docker.io/alpine:latest + +MAINTAINER Hende, Botond <nettingman@gmail.com> +LABEL Description="PaperMC server" + +RUN apk add --no-cache --virtual container-buildtime jq +RUN apk add --no-cache openjdk21 + +RUN mkdir /opt/minecraft + +RUN mkdir /tmp/papermc +COPY papermc_getlatest.sh /tmp/papermc/papermc_getlatest.sh +RUN /tmp/papermc/papermc_getlatest.sh +RUN rm -rf /tmp/papermc + +COPY start.sh /opt/minecraft/start.sh +RUN chown -R nobody:nobody /opt/minecraft + +RUN apk del container-buildtime + +WORKDIR /opt/minecraft +USER guest +EXPOSE 9001/tcp + +CMD ["/opt/minecraft/start.sh"] + diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..47c116a --- /dev/null +++ b/Makefile @@ -0,0 +1,110 @@ +name = $(notdir $(realpath .)) +host = $(name) +pwd = $(realpath .) +run-args = -itd --name $(host) +run-cmd = + + +default: build + + +build: build-buildah + +build-docker: + docker build --squash -t $(name) $(pwd) + +build-buildah: + buildah bud --squash --layers -t $(name) $(pwd) + + +run: run-podman + +run-docker: stop-docker build-docker wait start-docker + +run-podman: stop-podman build-buildah wait start-podman + + +start: start-podman + +start-docker: + docker run --rm --cpus 1 $(run-args) $(name) $(run-cmd) + +start-podman: + podman run --rm $(run-args) $(name) $(run-cmd) + + +stop: stop-podman + +stop-docker: + -docker stop $(name) + +stop-podman: + -podman stop $(name) + + +kill: kill-podman + +kill-docker: + -docker kill $(name) + +kill-podman: + -podman kill $(name) + + +restart: restart-podman + +restart-docker: + -docker restart $(name) + +restart-podman: + -podman restart $(name) + + +wait: + sleep 1 + + +log: log-podman + +log-docker: + docker logs $(name) + +log-podman: + podman logs $(name) + + +clean: clean-podman + +clean-docker: kill-docker wait + -docker image prune --force + -docker container prune --force + +clean-podman: kill-podman wait + -buildah rm -a + -podman image prune + -podman container prune --force + + +shell: shell-podman + +shell-docker: console-docker + +shell-podman: console-podman + + +console: console-podman + +console-docker: + docker exec -it $(name) /bin/bash + +console-podman: + podman exec -it $(name) /bin/bash + + +status: status-podman + +status-docker: + docker exec -it $(name) /usr/bin/supervisorctl status + +status-podman: + podman exec -it $(name) /usr/bin/supervisorctl status diff --git a/papermc_getlatest.sh b/papermc_getlatest.sh new file mode 100755 index 0000000..f8d0ca9 --- /dev/null +++ b/papermc_getlatest.sh @@ -0,0 +1,13 @@ +PROJECT="paper" +MINECRAFT_VERSION="1.20.4" + +LATEST_BUILD=$(curl -s https://api.papermc.io/v2/projects/${PROJECT}/versions/${MINECRAFT_VERSION}/builds | \ + jq -r '.builds | map(select(.channel == "default") | .build) | .[-1]') + +JAR_NAME=${PROJECT}-${MINECRAFT_VERSION}-${LATEST_BUILD}.jar + +PAPERMC_URL="https://api.papermc.io/v2/projects/${PROJECT}/versions/${MINECRAFT_VERSION}/builds/${LATEST_BUILD}/downloads/${JAR_NAME}" + +# Download the latest PaperMC version +curl -o /opt/minecraft/server.jar $PAPERMC_URL +echo "Downloads completed" diff --git a/start.sh b/start.sh new file mode 100644 index 0000000..ec22d03 --- /dev/null +++ b/start.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +java -Xmx2048M -Xms2048M -XX:+AlwaysPreTouch -XX:+DisableExplicitGC -XX:+ParallelRefProcEnabled -XX:+PerfDisableSharedMem -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1HeapRegionSize=8M -XX:G1HeapWastePercent=5 -XX:G1MaxNewSizePercent=40 -XX:G1MixedGCCountTarget=4 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1NewSizePercent=30 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:G1ReservePercent=20 -XX:InitiatingHeapOccupancyPercent=15 -XX:MaxGCPauseMillis=200 -XX:MaxTenuringThreshold=1 -XX:SurvivorRatio=32 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true -jar server.jar nogui
\ No newline at end of file |