Merge pull request 'feature-42 docker' (#1) from feature-42 into develop
All checks were successful
/ build-docker (push) Successful in 8m50s

Reviewed-on: #1
This commit is contained in:
cuqmbr 2025-06-06 18:00:34 +00:00
commit cae0f02eb2
45 changed files with 97 additions and 34 deletions

1
.dockerignore Normal file
View File

@ -0,0 +1 @@
*/logs

46
.github/workflows/build-docker.yml vendored Normal file
View File

@ -0,0 +1,46 @@
---
on:
push:
branches:
- main
- develop
jobs:
build-docker:
runs-on: ubuntu-latest
env:
registry: gitea.cuqmbr.xyz
steps:
- name: Login to Docker Container Registry
uses: docker/login-action@v3
with:
registry: ${{env.registry}}
username: ${{vars.DOCKER_USER}}
password: ${{secrets.DOCKER_TOKEN}}
- name: Checkout repository
uses: actions/checkout@v4
# https://github.com/actions/checkout/issues/1830
# https://gitea.com/gitea/act_runner/issues/164
- name: Checkout lfs
run: |
git lfs install --local
AUTH=$(git config --local http.${{ github.server_url }}/.extraheader)
git config --local --unset http.${{ github.server_url }}/.extraheader
git config --local http.${{ github.server_url }}/${{ github.repository }}.git/info/lfs/objects/batch.extraheader "$AUTH"
git lfs pull
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
platforms: linux/arm64,linux/amd64
push: true
# TODO: split tag names into multiple lines
tags: |
${{env.registry}}/${{github.repository_owner}}/${{github.event.repository.name}}/${{github.ref_name}}:${{github.sha}}
${{env.registry}}/${{github.repository_owner}}/${{github.event.repository.name}}/${{github.ref_name}}:latest

17
.gitignore vendored
View File

@ -1,16 +1 @@
cache */logs
libraries
logs
versions
world
world_nether
world_the_end
./.console_history
banned-ips.json
banned-players.json
ops.json
whitelist.json
usercache.json

33
Dockerfile Normal file
View File

@ -0,0 +1,33 @@
FROM sapmachine:21-jre-headless-ubuntu
ENV WORKDIR_PATH=/workspace
ENV CONFIG_PATH=${WORKDIR_PATH}/config
ENV DATA_PATH=${WORKDIR_PATH}/data
ADD ./src ${CONFIG_PATH}
RUN mkdir ${DATA_PATH}
RUN mkdir ${DATA_PATH}/logs && \
ln -sf ${DATA_PATH}/logs ${CONFIG_PATH}
VOLUME ${DATA_PATH}
ENV MEMORY=4G
ENV PROXY_SECRET=change_me
ENV SERVERS=lobby="lobby:25565";survival="survival:25565"
ENV TRY=lobby;survival
WORKDIR ${WORKDIR_PATH}/config
EXPOSE 25565/tcp
# TODO: Make awk commands sapn multiple lines
# TODO: Use one call to awk to perform substitutions
CMD \
sed -i "s/_PROXY_SECRET_/${PROXY_SECRET}/g" forwarding.secret && \
awk -v servers_str="${SERVERS}" '{ count=split(servers_str,servers_arr,";"); servers_fmt_str = ""; for (i = 1; i <= count; i++) servers_fmt_str = servers_fmt_str servers_arr[i] "\n"; sub(/_SERVERS_/,servers_fmt_str); print }' velocity.toml > velocity.toml.tmp && mv -T -f velocity.toml.tmp velocity.toml &&\
awk -v try_str="${TRY}" '{ count=split(try_str,try_arr,";"); try_fmt_str = ""; for (i = 1; i <= count; i++) try_fmt_str = try_fmt_str "\"" try_arr[i] "\"" ",\n "; sub(/_TRY_/,try_fmt_str); print }' velocity.toml > velocity.toml.tmp && mv -T -f velocity.toml.tmp velocity.toml && \
java -Xms${MEMORY} -Xmx${MEMORY} -XX:+UseG1GC -XX:G1HeapRegionSize=4M -XX:+UnlockExperimentalVMOptions -XX:+ParallelRefProcEnabled -XX:+AlwaysPreTouch -XX:MaxInlineLevel=15 -jar *.jar

View File

@ -1 +0,0 @@
gWlMDmsD2kAI

1
src/forwarding.secret Normal file
View File

@ -0,0 +1 @@
_PROXY_SECRET_

View File

@ -1,3 +1,3 @@
@echo off @echo off
java -Xms1G -Xmx1G -XX:+UseG1GC -XX:G1HeapRegionSize=4M -XX:+UnlockExperimentalVMOptions -XX:+ParallelRefProcEnabled -XX:+AlwaysPreTouch -XX:MaxInlineLevel=15 -jar velocity.jar java -Xms1G -Xmx1G -XX:+UseG1GC -XX:G1HeapRegionSize=4M -XX:+UnlockExperimentalVMOptions -XX:+ParallelRefProcEnabled -XX:+AlwaysPreTouch -XX:MaxInlineLevel=15 -jar *.jar
pause pause

View File

@ -1,3 +1,3 @@
#!/bin/sh #!/bin/sh
java -Xms1G -Xmx1G -XX:+UseG1GC -XX:G1HeapRegionSize=4M -XX:+UnlockExperimentalVMOptions -XX:+ParallelRefProcEnabled -XX:+AlwaysPreTouch -XX:MaxInlineLevel=15 -jar velocity*.jar java -Xms1G -Xmx1G -XX:+UseG1GC -XX:G1HeapRegionSize=4M -XX:+UnlockExperimentalVMOptions -XX:+ParallelRefProcEnabled -XX:+AlwaysPreTouch -XX:MaxInlineLevel=15 -jar *.jar

View File

@ -13,7 +13,7 @@ motd = "<#09add3>A Velocity Server"
show-max-players = 500 show-max-players = 500
# Should we authenticate players with Mojang? By default, this is on. # Should we authenticate players with Mojang? By default, this is on.
online-mode = true online-mode = false
# Should the proxy enforce the new public key security standard? By default, this is on. # Should the proxy enforce the new public key security standard? By default, this is on.
force-key-authentication = true force-key-authentication = true
@ -34,7 +34,7 @@ prevent-client-proxy-connections = false
# unable to implement network level firewalling (on a shared host). # unable to implement network level firewalling (on a shared host).
# - "modern": Forward player IPs and UUIDs as part of the login process using # - "modern": Forward player IPs and UUIDs as part of the login process using
# Velocity's native forwarding. Only applicable for Minecraft 1.13 or higher. # Velocity's native forwarding. Only applicable for Minecraft 1.13 or higher.
player-info-forwarding-mode = "NONE" player-info-forwarding-mode = "modern"
# If you are using modern or BungeeGuard IP forwarding, configure a file that contains a unique secret here. # If you are using modern or BungeeGuard IP forwarding, configure a file that contains a unique secret here.
# The file is expected to be UTF-8 encoded and not empty. # The file is expected to be UTF-8 encoded and not empty.
@ -77,26 +77,24 @@ enable-player-address-logging = true
[servers] [servers]
# Configure your servers here. Each key represents the server's name, and the value # Configure your servers here. Each key represents the server's name, and the value
# represents the IP address of the server to connect to. # represents the IP address of the server to connect to.
lobby = "127.0.0.1:30066" _SERVERS_
factions = "127.0.0.1:30067"
minigames = "127.0.0.1:30068"
# In what order we should try servers when a player logs in or is kicked from a server. # In what order we should try servers when a player logs in or is kicked from a server.
try = [ try = [
"lobby" _TRY_
] ]
[forced-hosts] [forced-hosts]
# Configure your forced hosts here. # Configure your forced hosts here.
"lobby.example.com" = [ # "lobby.example.com" = [
"lobby" # "lobby"
] # ]
"factions.example.com" = [ # "factions.example.com" = [
"factions" # "factions"
] # ]
"minigames.example.com" = [ # "minigames.example.com" = [
"minigames" # "minigames"
] # ]
[advanced] [advanced]
# How large a Minecraft packet has to be before we compress it. Setting this to zero will # How large a Minecraft packet has to be before we compress it. Setting this to zero will