-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
162 lines (147 loc) · 5.75 KB
/
Copy pathdocker-compose.yml
File metadata and controls
162 lines (147 loc) · 5.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#-------------------------------------------------#
# Docker Compose configuration for Gaming Servers #
#-------------------------------------------------#---------------------------------------------#
# The following are yaml anchors which are used to reduce redundancy #
# and simplify configuration across multiple services by defining common settings in one place. #
#-----------------------------------------------------------------------------------------------#
# Anchors for common Minecraft environment variables. Adjust as needed.
x-mc-default-config: &mc-default-config
./config/minecraft/${MC_DEFAULT_CONFIG:-server.properties.default}
x-mc-env-args: &mc-env-args
EULA: ${EULA}
INIT_MEMORY: "2G"
MAX_MEMORY: "4G"
MODE: "survival"
DIFFICULTY: "hard"
RCON_PASSWORD: ${RCON_PASSWORD} # Ensure this is set in your .env file. DO NOT PASTE YOUR PASSWORD DIRECTLY HERE.
ICON: /opt/stxsoft/assets/${ICON_FILE:-stxsoft/icon.png}
#-----------------------------------------------------------------------------------#
# Do not remove or edit the following anchors! #
# They are used in multiple places below and are necessary for proper configuration #
#-----------------------------------------------------------------------------------#
# Volume mapping for shared static resources (icons, etc)
x-resource-vol: &resource-vol
"./assets:/opt/stxsoft/assets/:ro"
# Target path for Minecraft server configuration file
# Do not change this unless you know what you're doing!
x-mc-cfg-target: &mc-cfg-target
"/server.properties"
# Template for Minecraft services to reduce redundancy
x-mc-template: &mc-template
build:
context: docker/minecraft
environment:
<<: *mc-env-args
configs:
- source: mc-vanilla-cfg
target: *mc-cfg-target
restart: unless-stopped
volumes:
- *resource-vol
#-----------------------------------#
# Main Docker Compose Configuration #
#-----------------------------------#
# Configuration files for Minecraft servers
# Create your custom server.properties files in the ./config/minecraft/ folder
# and reference them here. You can reference them when defining each server below.
configs:
mc-vanilla-cfg:
file: *mc-default-config
volumes:
valheim-server:
services:
# Playit.gg agent for tunneling
# Should not need any modifications unless you change the network subnet
playit:
image: ghcr.io/playit-cloud/playit-agent:0.16
networks:
gameserver-net:
ipv4_address: 172.30.0.2 # Only change if subnet is modified down below due to conflicts
environment:
- SECRET_KEY=${AGENT_SECRET} # Ensure this is set in your .env file. DO NOT PASTE YOU SECRET DIRECTLY HERE.
restart: unless-stopped
# Vanilla Minecraft Server
# This is where the fun begins!
# Modify the environment variables as needed to customize your server.
mc-vanilla:
<<: *mc-template
environment:
<<: *mc-env-args
VERSION: "1.21.5"
TYPE: "VANILLA"
SEED: "42"
# difficulty: peaceful # Uncomment to override default difficulty
# ports:
# - "25565:25565" # Uncomment if not using playit.gg or if direct access is needed. This can bypass NAT/firewall restrictions.
volumes:
- *resource-vol # Shared assets volume (read-only)
- ./servers/minecraft/vanilla:/data # Minecraft server files volume for persistence across restarts.
configs:
- source: mc-vanilla-cfg # Must match the name under 'configs' at the bottom of this file
target: *mc-cfg-target # Mandatory for the entrypoint script to pick up custom server.properties
deploy:
resources:
limits:
cpus: '4.0' # Limit to 4 CPU cores
memory: 5G # Limit to 5GB RAM
networks:
gameserver-net:
ipv4_address: 172.30.0.3 # Static IP for vanilla server within the custom network. Only change if subnet is modified down below due to conflicts
valheim:
image: lloesche/valheim-server
environment:
# Customize your Valheim server settings via environment variables
# More info on: https://hub.docker.com/r/lloesche/valheim-server
- SERVER_NAME=${VALHEIM_SERVER_NAME:-SyntexSoft Valheim Server}
- WORLD_NAME=${VALHEIM_WORLD_NAME:-STXS World}
- SERVER_PASS=${VALHEIM_PASSWORD}
- PUBLIC=${VALHEIM_PUBLIC:-false}
- PORT=${VALHEIM_PORT:-2456}
volumes:
- ./servers/valheim:/config
- valheim-server:/opt/valheim
expose:
- 2456-2457/udp
# - "${VALHEIM_PORT:-2456}:${VALHEIM_PORT:-2456}/udp"
# - "${VALHEIM_PORT_PLUS_ONE:-2457}:${VALHEIM_PORT_PLUS_ONE:-2457}/udp"
restart: unless-stopped
deploy:
resources:
limits:
cpus: '2.0'
memory: 4G
networks:
gameserver-net:
ipv4_address: 172.30.0.4
# Additional game servers can be added here following the same pattern as mc-vanilla.
# Ensure to assign unique static IPs within the custom network subnet.
# Example for a modded Minecraft server using Forge:
# mc-modded:
# <<: *mc-template
# environment:
# <<: *mc-env-args
# VERSION: "1.16.5"
# TYPE: "FORGE"
# FORGE_VERSION: "36.2.0"
# INIT_MEMORY: "4G"
# MAX_MEMORY: "12G"
# volumes:
# - *resource-vol
# - ./servers/minecraft/modded:/data
# networks:
# gameserver-net:
# ipv4_address: 172.30.0.5
# deploy:
# resources:
# limits:
# cpus: '4.0'
# memory: 12G
# Custom network to isolate game servers and playit agent
networks:
gameserver-net:
name: gameserver-net
driver: bridge
internal: true
ipam:
config:
- subnet: 172.30.0.0/16 # Custom subnet to avoid conflicts (Adjust as needed, ensure it doesn't overlap with existing networks on your host)