From 379bb85a428dc916cfe872ee33015b236c46fab4 Mon Sep 17 00:00:00 2001 From: Kappeh Date: Fri, 16 Jan 2026 05:31:55 +0000 Subject: [PATCH] Switch from bind mounts to named docker volumes --- .gitignore | 48 ------ {backups => bluemap/config/packs}/.keep | 0 bluemap/data/.keep | 0 bluemap/maps/.keep | 0 compose.yml | 140 ++++++++++++------ fabric/data/bluemap/web/maps/.keep | 0 fabric/data/config/worldedit/schematics/.keep | 0 paper/data/bluemap/web/maps/.keep | 0 paper/data/plugins/WorldEdit/schematics/.keep | 0 scripts/init_volumes.sh | 30 ++++ template.env | 3 + .../plugins/dclink-velocity/dclink.conf | 6 +- velocity/data/.keep | 0 13 files changed, 130 insertions(+), 97 deletions(-) rename {backups => bluemap/config/packs}/.keep (100%) mode change 100755 => 100644 delete mode 100755 bluemap/data/.keep delete mode 100755 bluemap/maps/.keep delete mode 100755 fabric/data/bluemap/web/maps/.keep delete mode 100755 fabric/data/config/worldedit/schematics/.keep delete mode 100755 paper/data/bluemap/web/maps/.keep delete mode 100755 paper/data/plugins/WorldEdit/schematics/.keep create mode 100755 scripts/init_volumes.sh delete mode 100755 velocity/data/.keep diff --git a/.gitignore b/.gitignore index 2a04d34..7058de9 100755 --- a/.gitignore +++ b/.gitignore @@ -4,51 +4,3 @@ # Ignore environment variable files containing secrets. /.env -# Docker volumes -/velocity/data/** -!/velocity/data/.keep - -/luckperms/data/** -!/luckperms/data/.keep - -/schematics/** - -/paper/data/** -!/paper/data/bukkit.yml -!/paper/data/spigot.yml -!/paper/data/commands.yml -!/paper/data/plugins -!/paper/data/plugins/WorldEdit -!/paper/data/plugins/WorldEdit/schematics/ -!/paper/data/plugins/WorldEdit/schematics/.keep -!/paper/data/bluemap -!/paper/data/bluemap/web -!/paper/data/bluemap/web/maps -!/paper/data/bluemap/web/maps/.keep - -/fabric/data/** -!/fabric/data/config -!/fabric/data/config/worldedit -!/fabric/data/config/worldedit/schematics -!/fabric/data/config/worldedit/schematics/.keep -!/fabric/data/bluemap -!/fabric/data/bluemap/web -!/fabric/data/bluemap/web/maps -!/fabric/data/bluemap/web/maps/.keep - -/bluemap/data/** -!/bluemap/data/.keep - -/bluemap/maps/** -!/bluemap/maps/.keep - -/bluemap/web/** -!/bluemap/web/.keep - -# Backups -/backups/** -!/backups/.keep - -# Java binaries -/paper/plugins/*.jar - diff --git a/backups/.keep b/bluemap/config/packs/.keep old mode 100755 new mode 100644 similarity index 100% rename from backups/.keep rename to bluemap/config/packs/.keep diff --git a/bluemap/data/.keep b/bluemap/data/.keep deleted file mode 100755 index e69de29..0000000 diff --git a/bluemap/maps/.keep b/bluemap/maps/.keep deleted file mode 100755 index e69de29..0000000 diff --git a/compose.yml b/compose.yml index 6d99df3..916bf8a 100755 --- a/compose.yml +++ b/compose.yml @@ -1,31 +1,33 @@ services: velocity: image: itzg/mc-proxy:java21-2025.1.0 - container_name: illegal_crime_velocity + container_name: minecraft_server_velocity user: 2015:2015 # minecraft_server:minecraft_server restart: unless-stopped depends_on: + init_volumes: + condition: service_completed_successfully + luckperms_db: + condition: service_healthy + restart: true fabric: condition: service_healthy restart: true paper: condition: service_healthy restart: true - luckperms_db: - condition: service_healthy - restart: true secrets: - rcon_password - forwarding_secret - dclink_token - luckperms_db_password networks: - illegal_crime_mc_network: + minecraft_server_network: ipv4_address: "10.100.1.3" ports: - 25000:25565 volumes: - - ./velocity/data:/server:rw + - velocity_data:/server:rw - ./velocity/config:/config:ro environment: TYPE: VELOCITY @@ -36,12 +38,15 @@ services: REPLACE_ENV_VARIABLES: true ENV_VARIABLE_PREFIX: CFG_ - + ENABLE_RCON: true RCON_PORT: 25575 RCON_PASSWORD_FILE: /run/secrets/rcon_password CFG_RCON_PASSWORD_FILE: /run/secrets/rcon_password + CFG_DCLINK_GUILD: ${DCLINK_GUILD} + CFG_DCLINK_CHANNEL: ${DCLINK_CHANNEL} + CFG_DCLINK_ROLE: ${DCLINK_ROLE} CFG_DCLINK_TOKEN_FILE: /run/secrets/dclink_token CFG_LUCKPERMS_DB_PASSWORD_FILE: /run/secrets/luckperms_db_password @@ -56,10 +61,12 @@ services: bluemap: image: ghcr.io/bluemap-minecraft/bluemap:v5.7 - container_name: illegal_crime_bluemap + container_name: minecraft_server_bluemap user: 2015:2015 # minecraft_server:minecraft_server restart: unless-stopped depends_on: + init_volumes: + condition: service_completed_successfully fabric: condition: service_healthy restart: true @@ -68,21 +75,23 @@ services: restart: true command: -g -w networks: - illegal_crime_mc_network: + minecraft_server_network: ipv4_address: "10.100.1.6" ports: - 8100:8100 volumes: - - ./bluemap/data:/app/data:rw - - ./bluemap/web:/app/web:rw - - ./bluemap/config:/app/config:rw - - ./bluemap/maps:/app/web/maps:ro + - bluemap_data:/app/data:rw + - bluemap_web:/app/web:rw + - bluemap_maps:/app/web/maps:ro + - ./bluemap/config:/app/config:ro paper: image: itzg/minecraft-server:2025.3.0-java23 - container_name: illegal_crime_paper + container_name: minecraft_server_paper restart: unless-stopped depends_on: + init_volumes: + condition: service_completed_successfully luckperms_db: condition: service_healthy restart: true @@ -96,14 +105,17 @@ services: - forwarding_secret - luckperms_db_password networks: - illegal_crime_mc_network: + minecraft_server_network: ipv4_address: "10.100.1.4" volumes: - - ./paper/data:/data:rw + - paper_data:/data:rw + - schematics:/data/plugins/WorldEdit/schematics:rw + - bluemap_maps:/data/bluemap/web/maps:rw - ./paper/config:/config:ro - ./paper/plugins:/plugins:ro - - ./schematics:/data/plugins/WorldEdit/schematics:rw - - ./bluemap/maps:/data/bluemap/web/maps:rw + - ./paper/data/bukkit.yml:/data/bukkit.yml:ro + - ./paper/data/commands.yml:/data/commands.yml:ro + - ./paper/data/spigot.yml:/data/spigot.yml:ro environment: UID: 2015 # minecraft_server GID: 2015 # minecraft_server @@ -125,22 +137,22 @@ services: BROADCAST_CONSOLE_TO_OPS: false BROADCAST_RCON_TO_OPS: false - + ONLINE_MODE: false OP_PERMISSION_LEVEL: 2 MAX_PLAYERS: 50 DIFFICULTY: easy LEVEL: survival - + MODE: creative - LEVEL_TYPE: minecraft:default + LEVEL_TYPE: minecraft:normal ENABLE_COMMAND_BLOCK: true GENERATE_STRUCTURES: false SPAWN_ANIMALS: false SPAWN_MONSTERS: false SPAWN_NPCS: false SPAWN_PROTECTION: 0 - + USE_AIKAR_FLAGS: true LOG_TIMESTAMP: true @@ -155,7 +167,7 @@ services: CFG_RCON_PASSWORD_FILE: /run/secrets/rcon_password CFG_FORWARDING_SECRET_FILE: /run/secrets/forwarding_secret CFG_LUCKPERMS_DB_PASSWORD_FILE: /run/secrets/luckperms_db_password - + PLUGINS: | https://github.com/EssentialsX/Essentials/releases/download/2.20.1/EssentialsX-2.20.1.jar @@ -171,12 +183,14 @@ services: stfu-velocity:Y3nJXOQT vaultunlocked:fC53e1Vr worldedit:4jRlujfz - + fabric: image: itzg/minecraft-server:2025.3.0-java23 - container_name: illegal_crime_fabric + container_name: minecraft_server_fabric restart: unless-stopped depends_on: + init_volumes: + condition: service_completed_successfully luckperms_db: condition: service_healthy restart: true @@ -190,13 +204,13 @@ services: - forwarding_secret - luckperms_db_password networks: - illegal_crime_mc_network: + minecraft_server_network: ipv4_address: "10.100.1.5" volumes: - - ./fabric/data:/data:rw + - fabric_data:/data:rw + - schematics:/data/config/worldedit/schematics:rw + - bluemap_maps:/data/bluemap/web/maps:rw - ./fabric/config:/config:ro - - ./schematics:/data/config/worldedit/schematics:rw - - ./bluemap/maps:/data/bluemap/web/maps:rw environment: UID: 2015 # minecraft_server GID: 2015 # minecraft_server @@ -217,13 +231,13 @@ services: BROADCAST_CONSOLE_TO_OPS: false BROADCAST_RCON_TO_OPS: false - + ONLINE_MODE: false OP_PERMISSION_LEVEL: 2 MAX_PLAYERS: 50 DIFFICULTY: easy LEVEL: world - + MODE: creative LEVEL_TYPE: minecraft:flat ENABLE_COMMAND_BLOCK: true @@ -232,7 +246,7 @@ services: SPAWN_MONSTERS: false SPAWN_NPCS: false SPAWN_PROTECTION: 0 - + USE_AIKAR_FLAGS: true LOG_TIMESTAMP: true @@ -286,9 +300,12 @@ services: luckperms_db: image: postgres:17.4 - container_name: illegal_crime_luckperms_db + container_name: minecraft_server_luckperms_db user: 2015:2015 # minecraft_server:minecraft_server restart: unless-stopped + depends_on: + init_volumes: + condition: service_completed_successfully healthcheck: test: ["CMD-SHELL", "pg_isready -U luckperms -d luckperms"] interval: 10s @@ -298,20 +315,52 @@ services: secrets: - luckperms_db_password networks: - illegal_crime_mc_network: + minecraft_server_network: ipv4_address: "10.100.1.2" ports: - 5434:5432 volumes: + - luckperms_data:/var/lib/postgresql/data:rw - /etc/passwd:/etc/passwd:ro - - ./luckperms/data:/var/lib/postgresql/data:rw - - ./backups:/backups:rw + # - ./backups:/backups:rw environment: POSTGRES_PASSWORD_FILE: /run/secrets/luckperms_db_password POSTGRES_USER: luckperms POSTGRES_DB: luckperms PGDATA: /var/lib/postgresql/data/pgdata + init_volumes: + container_name: minecraft_server_init_volumes + image: busybox:1.37.0 + user: root:root + command: /init_volumes.sh + restart: no + network_mode: none + volumes: + - ./scripts/init_volumes.sh:/init_volumes.sh:ro + # Used for resolving user and group names within the init script + - /etc/passwd:/etc/passwd:ro + - /etc/group:/etc/group:ro + # Mount all named volumes so they can be initialised + - velocity_data:/velocity_data:rw + - bluemap_data:/bluemap_data:rw + - bluemap_web:/bluemap_web:rw + - bluemap_maps:/bluemap_maps:rw + - schematics:/schematics:rw + - paper_data:/paper_data:rw + - fabric_data:/fabric_data:rw + - luckperms_data:/luckperms_data:rw + +networks: + minecraft_server_network: + name: minecraft_server_network + driver: bridge + ipam: + driver: default + config: + - subnet: "10.100.1.0/24" + gateway: "10.100.1.1" + secrets: rcon_password: environment: RCON_PASSWORD @@ -322,13 +371,12 @@ secrets: luckperms_db_password: environment: LUCKPERMS_DB_PASSWORD -networks: - illegal_crime_mc_network: - name: illegal_crime_mc_network - driver: bridge - ipam: - driver: default - config: - - subnet: "10.100.1.0/24" - gateway: "10.100.1.1" - +volumes: + velocity_data: + bluemap_data: + bluemap_web: + bluemap_maps: + schematics: + paper_data: + fabric_data: + luckperms_data: diff --git a/fabric/data/bluemap/web/maps/.keep b/fabric/data/bluemap/web/maps/.keep deleted file mode 100755 index e69de29..0000000 diff --git a/fabric/data/config/worldedit/schematics/.keep b/fabric/data/config/worldedit/schematics/.keep deleted file mode 100755 index e69de29..0000000 diff --git a/paper/data/bluemap/web/maps/.keep b/paper/data/bluemap/web/maps/.keep deleted file mode 100755 index e69de29..0000000 diff --git a/paper/data/plugins/WorldEdit/schematics/.keep b/paper/data/plugins/WorldEdit/schematics/.keep deleted file mode 100755 index e69de29..0000000 diff --git a/scripts/init_volumes.sh b/scripts/init_volumes.sh new file mode 100755 index 0000000..7357a82 --- /dev/null +++ b/scripts/init_volumes.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env sh + +# Define a helper function that runs a command +# If the command fails, the script prints an error message +# and exits immediately. +run() { + # "$@" expands to all arguments passed to this function + # and preserves proper word splitting and quoting. + "$@" || { + echo "Error: command failed: $*" >&2 + exit 1 + } +} + +# Ensure required directories exist +run mkdir -p /fabric_data/bluemap/web/maps +run mkdir -p /fabric_data/config/worldedit/schematics +run mkdir -p /paper_data/bluemap/web/maps +run mkdir -p /paper_data/plugins/WorldEdit/schematics + +# Ensure correct permissions of docker volumes +run chown -R minecraft_server:minecraft_server /bluemap_data +run chown -R minecraft_server:minecraft_server /bluemap_web +run chown -R minecraft_server:minecraft_server /bluemap_maps +run chown -R minecraft_server:minecraft_server /fabric_data +run chown -R minecraft_server:minecraft_server /luckperms_data +run chown -R minecraft_server:minecraft_server /paper_data +run chown -R minecraft_server:minecraft_server /schematics +run chown -R minecraft_server:minecraft_server /velocity_data + diff --git a/template.env b/template.env index f6e1ecd..4bfd9eb 100755 --- a/template.env +++ b/template.env @@ -2,6 +2,9 @@ RCON_PASSWORD=${CFG_RCON_PASSWORD} FORWARDING_SECRET=${CFG_FORWARDING_SECRET} +DCLINK_GUILD=${CFG_DCLINK_GUILD} +DCLINK_CHANNEL=${CFG_DCLINK_CHANNEL} +DCLINK_ROLE=${CFG_DCLINK_ROLE} DCLINK_TOKEN=${CFG_DCLINK_TOKEN} LUCKPERMS_DB_PASSWORD=${CFG_LUCKPERMS_DB_PASSWORD} diff --git a/velocity/config/plugins/dclink-velocity/dclink.conf b/velocity/config/plugins/dclink-velocity/dclink.conf index 7f65b50..46d41a4 100755 --- a/velocity/config/plugins/dclink-velocity/dclink.conf +++ b/velocity/config/plugins/dclink-velocity/dclink.conf @@ -4,11 +4,11 @@ database { } discord { # Guild ID of the Guild where the bot will run - guild="1204371192727867393" + guild="${CFG_DCLINK_GUILD}" # Channel ID of the channel where the bot will send the message with the button to link their account - link-channel="1206721349087793192" + link-channel="${CFG_DCLINK_CHANNEL}" # Role ID of the role that the bot will give to the linked players (If left blank, the bot will not give any roles) - link-role="1206721407568969729" + link-role="${CFG_DCLINK_ROLE}" # Message to show on the bot's status status-message=Minecraft # Bot Token (see https://discord.com/developers/applications) diff --git a/velocity/data/.keep b/velocity/data/.keep deleted file mode 100755 index e69de29..0000000