commit dede9ce18d568966777cc1832a0ad1706424c94e Author: kento2 Date: Sun Aug 16 00:26:34 2026 +0200 . diff --git a/TODO b/TODO new file mode 100644 index 0000000..462cc03 --- /dev/null +++ b/TODO @@ -0,0 +1 @@ +ci/cd to publish images diff --git a/data/build-server/config/paper-global.yml b/data/build-server/config/paper-global.yml new file mode 100644 index 0000000..f1973fa --- /dev/null +++ b/data/build-server/config/paper-global.yml @@ -0,0 +1,145 @@ +# This is the global configuration file for Paper. +# As you can see, there's a lot to configure. Some options may impact gameplay, so use +# with caution, and make sure you know what each option does before configuring. +# +# If you need help with the configuration or have any questions related to Paper, +# join us in our Discord or check the docs page. +# +# The world configuration options have been moved inside +# their respective world folder. The files are named paper-world.yml +# +# File Reference: https://docs.papermc.io/paper/reference/global-configuration/ +# Docs: https://docs.papermc.io/ +# Discord: https://discord.gg/papermc +# Website: https://papermc.io/ + +_version: 31 +anticheat: + obfuscation: + items: + all-models: + also-obfuscate: [] + dont-obfuscate: + - minecraft:lodestone_tracker + sanitize-count: true + enable-item-obfuscation: false + model-overrides: + minecraft:elytra: + also-obfuscate: [] + dont-obfuscate: + - minecraft:damage + sanitize-count: true +block-updates: + disable-chorus-plant-updates: false + disable-mushroom-block-updates: false + disable-noteblock-updates: false + disable-tripwire-updates: false +chunk-loading-advanced: + auto-config-send-distance: true + player-max-concurrent-chunk-generates: 0 + player-max-concurrent-chunk-loads: 0 +chunk-loading-basic: + player-max-chunk-generate-rate: -1.0 + player-max-chunk-load-rate: 100.0 + player-max-chunk-send-rate: 75.0 +chunk-system: + io-threads: -1 + worker-threads: -1 +collisions: + enable-player-collisions: true + send-full-pos-for-hard-colliding-entities: true +commands: + ride-command-allow-player-as-vehicle: false + suggest-player-names-when-null-tab-completions: true + time-command-affects-all-worlds: false +console: + enable-brigadier-completions: true + enable-brigadier-highlighting: true + has-all-permissions: false +item-validation: + book: + author: 8192 + page: 16384 + title: 8192 + book-size: + page-max: 2560 + total-multiplier: 0.98 + display-name: 8192 + lore-line: 8192 + resolve-selectors-in-books: false +logging: + deobfuscate-stacktraces: true +messages: + kick: + authentication-servers-down: + connection-throttle: Connection throttled! Please wait before reconnecting. + flying-player: + flying-vehicle: + no-permission: I'm sorry, but you do not have permission to perform this command. + Please contact the server administrators if you believe that this is in error. + use-display-name-in-quit-message: false +misc: + chat-threads: + chat-executor-core-size: -1 + chat-executor-max-size: -1 + client-interaction-leniency-distance: default + compression-level: default + enable-nether: true + fix-far-end-terrain-generation: true + load-permissions-yml-before-plugins: true + max-joins-per-tick: 5 + prevent-negative-villager-demand: false + region-file-cache-size: 256 + send-full-pos-for-item-entities: false + strict-advancement-dimension-check: false + use-alternative-luck-formula: false + use-dimension-type-for-custom-spawners: false + xp-orb-groups-per-area: default +packet-limiter: + all-packets: + action: KICK + interval: 7.0 + max-packet-rate: 500.0 + kick-message: + overrides: + minecraft:place_recipe: + action: DROP + interval: 4.0 + max-packet-rate: 5.0 +player-auto-save: + max-per-tick: -1 + rate: -1 +proxies: + velocity: + enabled: true + online-mode: true + secret: '1234' +scoreboards: + save-empty-scoreboard-teams: true + track-plugin-scoreboards: false +spam-limiter: + incoming-packet-threshold: 300 + recipe-spam-increment: 1 + recipe-spam-limit: 20 + tab-spam-increment: 1 + tab-spam-limit: 500 +spark: + enable-immediately: false + enabled: true +unsupported-settings: + allow-headless-pistons: false + allow-permanent-block-break-exploits: false + allow-piston-duplication: false + allow-unsafe-end-portal-teleportation: false + compression-format: ZLIB + oversized-item-component-sanitizer: + dont-sanitize: [] + perform-username-validation: true + skip-tripwire-hook-placement-validation: false + skip-vanilla-damage-tick-when-shield-blocked: false + update-equipment-on-player-actions: true +update-checker: + enabled: true +watchdog: + early-warning-delay: 10000 + early-warning-every: 5000 diff --git a/data/build-server/server.properties b/data/build-server/server.properties new file mode 100644 index 0000000..5f10d0d --- /dev/null +++ b/data/build-server/server.properties @@ -0,0 +1,70 @@ +#Minecraft server properties +#Thu Jul 09 11:56:34 GMT 2026 +accepts-transfers=false +allow-flight=false +broadcast-console-to-ops=true +broadcast-rcon-to-ops=true +bug-report-link= +debug=false +difficulty=easy +enable-code-of-conduct=false +enable-jmx-monitoring=false +enable-query=false +enable-rcon=false +enable-status=true +enforce-secure-profile=false +enforce-whitelist=false +entity-broadcast-range-percentage=100 +force-gamemode=false +function-permission-level=2 +gamemode=survival +generate-structures=true +generator-settings={} +hardcore=false +hide-online-players=false +initial-disabled-packs= +initial-enabled-packs=vanilla +level-name=world +level-seed= +level-type=minecraft\:normal +log-ips=true +management-server-allowed-origins= +management-server-enabled=false +management-server-host=localhost +management-server-port=0 +management-server-secret=PzbLDwG7Wr9xGAgxHiVHLLqy6SG7bxY1niCc8vmR +management-server-tls-enabled=true +management-server-tls-keystore= +management-server-tls-keystore-password= +max-chained-neighbor-updates=1000000 +max-players=20 +max-tick-time=60000 +max-world-size=29999984 +motd=A Minecraft Server +network-compression-threshold=256 +online-mode=false +op-permission-level=4 +pause-when-empty-seconds=60 +player-idle-timeout=0 +prevent-proxy-connections=false +query.port=25565 +rate-limit=0 +rcon.password= +rcon.port=25575 +region-file-compression=deflate +require-resource-pack=false +resource-pack= +resource-pack-id= +resource-pack-prompt= +resource-pack-sha1= +server-ip= +server-port=25565 +simulation-distance=10 +spawn-protection=16 +status-heartbeat-interval=0 +sync-chunk-writes=true +text-filtering-config= +text-filtering-version=0 +use-native-transport=true +view-distance=10 +white-list=false diff --git a/images/.gitignore b/images/.gitignore new file mode 100644 index 0000000..3af0ccb --- /dev/null +++ b/images/.gitignore @@ -0,0 +1 @@ +/data diff --git a/images/bazel-java/.mk.sh.swp b/images/bazel-java/.mk.sh.swp new file mode 100644 index 0000000..f24e4c9 Binary files /dev/null and b/images/bazel-java/.mk.sh.swp differ diff --git a/images/bazel-java/Containerfile b/images/bazel-java/Containerfile new file mode 100644 index 0000000..366ec4c --- /dev/null +++ b/images/bazel-java/Containerfile @@ -0,0 +1,5 @@ +FROM docker.io/fedora:45 +RUN dnf install -y java-25-openjdk-devel git gcc nodejs bazelisk +RUN bazelisk +RUN ln -s /usr/bin/bazelisk /usr/local/bin/bazel +ENV JAVA_HOME=/usr/lib/jvm/java-25-openjdk diff --git a/images/bazel-java/Makefile b/images/bazel-java/Makefile new file mode 100644 index 0000000..3ca8225 --- /dev/null +++ b/images/bazel-java/Makefile @@ -0,0 +1,3 @@ +include ../container.mk +TAG := bazel-java +VERSION := 0.12 diff --git a/images/container.mk b/images/container.mk new file mode 100644 index 0000000..ef29dbd --- /dev/null +++ b/images/container.mk @@ -0,0 +1,7 @@ +build: + podman build -f Containerfile -t $(TAG):$(VERSION) . + +publish: build + podman push localhost/$(TAG):$(VERSION) git.lab0x13.site/scrow/$(TAG):$(VERSION) + +.PHONY: build publish diff --git a/images/papermc/Containerfile b/images/papermc/Containerfile new file mode 100644 index 0000000..2e54c0c --- /dev/null +++ b/images/papermc/Containerfile @@ -0,0 +1,19 @@ +FROM docker.io/eclipse-temurin:25-jre-alpine +EXPOSE 25565 + +ENV MINECRAFT_VERSION=26.2 + +VOLUME /mnt +COPY --chmod=755 entrypoint.sh /entrypoint.sh + +WORKDIR /data +RUN apk add --no-cache curl jq +RUN curl -s "https://fill.papermc.io/v3/projects/paper/versions/$MINECRAFT_VERSION/builds/latest" \ + | jq -r '.downloads."server:default".url' \ + | xargs curl -o server.jar + +RUN printf eula=true > eula.txt +RUN java -jar server.jar --initSettings + +ENTRYPOINT ["/entrypoint.sh"] +CMD ["java", "-jar", "server.jar", "--nogui"] diff --git a/images/papermc/Makefile b/images/papermc/Makefile new file mode 100644 index 0000000..8a26526 --- /dev/null +++ b/images/papermc/Makefile @@ -0,0 +1,3 @@ +include ../container.mk +TAG := papermc +VERSION := 0.1 diff --git a/images/papermc/README b/images/papermc/README new file mode 100644 index 0000000..b897cfa --- /dev/null +++ b/images/papermc/README @@ -0,0 +1,3 @@ +This is the papermc image, base of all other minecraft instances. + +The server is initialized at build time to reduce startup time. diff --git a/images/papermc/entrypoint.sh b/images/papermc/entrypoint.sh new file mode 100755 index 0000000..1b0986b --- /dev/null +++ b/images/papermc/entrypoint.sh @@ -0,0 +1,6 @@ +#!/bin/sh +set -ex + +cd /data +cp -rf /mnt/* . || true +exec "$@" diff --git a/images/velocity/Containerfile b/images/velocity/Containerfile new file mode 100644 index 0000000..fef99c5 --- /dev/null +++ b/images/velocity/Containerfile @@ -0,0 +1,16 @@ +FROM docker.io/eclipse-temurin:25-jre-alpine +EXPOSE 25565 + +ENV VELOCITY_VERSION="4.1.0-SNAPSHOT" + +VOLUME /mnt +COPY --chmod=755 entrypoint.sh /entrypoint.sh +WORKDIR /data + +RUN apk add --no-cache curl jq +RUN curl -s "https://fill.papermc.io/v3/projects/velocity/versions/$VELOCITY_VERSION/builds/latest" \ + | jq -r '.downloads."server:default".url' \ + | xargs curl -o server.jar + +ENTRYPOINT ["/entrypoint.sh"] +CMD ["java", "-jar", "server.jar"] diff --git a/images/velocity/Makefile b/images/velocity/Makefile new file mode 100644 index 0000000..d4be001 --- /dev/null +++ b/images/velocity/Makefile @@ -0,0 +1,3 @@ +include ../container.mk +TAG := velocity +VERSION := 0.1 diff --git a/images/velocity/README b/images/velocity/README new file mode 100644 index 0000000..b897cfa --- /dev/null +++ b/images/velocity/README @@ -0,0 +1,3 @@ +This is the papermc image, base of all other minecraft instances. + +The server is initialized at build time to reduce startup time. diff --git a/images/velocity/entrypoint.sh b/images/velocity/entrypoint.sh new file mode 100755 index 0000000..1b0986b --- /dev/null +++ b/images/velocity/entrypoint.sh @@ -0,0 +1,6 @@ +#!/bin/sh +set -ex + +cd /data +cp -rf /mnt/* . || true +exec "$@" diff --git a/jobs/README.md b/jobs/README.md new file mode 100644 index 0000000..cbebc59 --- /dev/null +++ b/jobs/README.md @@ -0,0 +1,41 @@ +# Overview + +So we have some machines(we call those "nodes") +and each of those nodes runs (1) a nomad client; and (2) a consul client. +Also, all these nodes are in a wireguard network. + +nomad is responsible for actually deploying the servers on an available machine. +actually the Nomad *Server* has state and knows what all clients are doing, +while Nomad *Clients* are just doing what the server tells them to, like deploying +a job. + +A job is just a docker container, or the smallest deployable unit ig. + +the same server-client-relationship exists with consul. Here, Consul's main +purpose is to resolve hosts. A job registers itself (via a Consul Client) like +"hey im a postgres server and i run on 10.0.2.1:5432" and then the Consul Master +updates its catalogue: "oh so postgres is 10.0.2.1:5432" and then in our jobs, we +can just use "postgres.service.consul" and it resolves to 10.0.2.1:5432 so thats cool. + +Now wireguard is needed because while consul resolves hostnames, it doesn't help +us connect to the resolved IPs. With a single node, that's fine but if we want to +access a service on another node, we need wireguard(or something similar). +Actually if we run all nodes in the same network and it'd be fine without. + + + +## Most Basic Implementation + +- single node +- runs `nomad agent -dev` and `consul agent -dev` +- /etc/nomad.d/consul.hcl: + consul { + address = "127.0.0.1:8500" + } +- all jobs define a consul service + + +## useful commands + +- `nomad job run .hcl` +- `consul catalog services` <- list registered services diff --git a/jobs/lobby.nomad.hcl b/jobs/lobby.nomad.hcl new file mode 100644 index 0000000..8286f84 --- /dev/null +++ b/jobs/lobby.nomad.hcl @@ -0,0 +1,47 @@ +job "lobby" { + type = "service" + + group "lobby" { + count = 1 + + network { + mode = "host" + port "minecraft" { + to = 25565 + } + } + + task "run" { + driver = "docker" + + config { + image = "git.lab0x13.site/scrow/papermc:0.1" + force_pull = false + ports = ["minecraft"] + #args = ["java", "-jar", "server.jar", "--port=${NOMAD_PORT_minecraft}"] + } + + env { + HOST_POSTGRES = "jdbc:postgresql://postgres.service.consul/scrow" + HOST_NATS = "nats://nats.service.consul" + } + + resources { + cpu = 1000 + memory = 2048 + } + + service { + name = "lobby" + port = "minecraft" + provider = "consul" + + check { + type = "tcp" + interval = "5s" + timeout = "1s" + } + } + } + } +} diff --git a/jobs/nats.nomad.hcl b/jobs/nats.nomad.hcl new file mode 100644 index 0000000..83f6fb7 --- /dev/null +++ b/jobs/nats.nomad.hcl @@ -0,0 +1,39 @@ +job "nats" { + type = "service" + + group "nats" { + + network { + mode = "host" + port "nats" { + to = 4222 + } + } + + task "nats" { + driver = "docker" + + config { + image = "nats:alpine" + ports = ["nats"] + } + + resources { + cpu = 500 + memory = 1000 + } + + service { + name = "nats" + port = "nats" + provider = "consul" + + check { + type = "tcp" + interval = "5s" + timeout = "1s" + } + } + } + } +} diff --git a/jobs/postgresql.nomad.hcl b/jobs/postgresql.nomad.hcl new file mode 100644 index 0000000..f93f374 --- /dev/null +++ b/jobs/postgresql.nomad.hcl @@ -0,0 +1,45 @@ +job "postgres" { + datacenters = ["dc1"] + type = "service" + + group "db" { + network { + mode = "host" + port "postgres" { + to = 5432 + } + } + + task "postgres" { + driver = "docker" + + config { + image = "postgres:18-alpine" + ports = ["postgres"] + } + + env { + POSTGRES_USER = "postgres" + POSTGRES_DB = "scrow" + POSTGRES_HOST_AUTH_METHOD = "trust" + } + + resources { + cpu = 500 + memory = 512 + } + + service { + name = "postgres" + port = "postgres" + provider = "consul" + + check { + type = "tcp" + interval = "10s" + timeout = "1s" + } + } + } + } +} diff --git a/jobs/velocity.nomad.hcl b/jobs/velocity.nomad.hcl new file mode 100644 index 0000000..6dddee2 --- /dev/null +++ b/jobs/velocity.nomad.hcl @@ -0,0 +1,22 @@ +job "velocity" { + type = "service" + + group "proxy" { + network { + port "minecraft" { + static = 25565 + } + } + + task "velocity" { + driver = "docker" + config { + image = "scrow/velocity:local" + } + resources { + cpu = 2000 + memory = 1000 + } + } + } +}