forked from A1mDev/hlstatsx-community-edition
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathdocker-compose.example.yml
292 lines (274 loc) · 9.77 KB
/
docker-compose.example.yml
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
version: '2.2'
services:
# 1. Counter-Strike 1.6 gameserver sends UDP logs to the daemon
# See: https://github.com/startersclan/docker-sourceservers
cstrike:
image: goldsourceservers/cstrike:latest
ports:
- 27015:27015/udp
networks:
default:
ipv4_address: 10.5.0.100 # Static IP
stdin_open: true
tty: true
stop_signal: SIGKILL
entrypoint:
- /bin/bash
command:
- -c
- |
set -eu
exec hlds_linux -console -noipx -secure -game cstrike +map de_dust2 +maxplayers 32 +sv_lan 0 +ip 0.0.0.0 +port 27015 +rcon_password password +log on +logaddress_add 10.5.0.50 27500
# Uncomment to test CS2
# 1. Counter-Strike 2 gameserver sends HTTP logs to source-udp-forwarder
# See: https://github.com/startersclan/docker-sourceservers
# cs2:
# image: sourceservers/cs2:latest
# ports:
# - 27016:27016/tcp
# - 27016:27016/udp
# networks:
# default:
# ipv4_address: 10.5.0.101 # Static IP
# stdin_open: true
# tty: true
# stop_signal: SIGKILL
# depends_on:
# - source-udp-forwarder-cs2
# entrypoint:
# - /bin/bash
# command:
# - -c
# - |
# set -eu
# exec game/bin/linuxsteamrt64/cs2 -dedicated -port 27016 +game_type 0 +game_mode 1 +mapgroup mg_active +map de_dust2 +rcon_password password +log on +logaddress_add_http "http://source-udp-forwarder-cs2:26999"
# Uncomment to test CS2
# 2. source-udp-forwarder proxy forwards gameserver logs to the daemon
# See: https://github.com/startersclan/source-udp-forwarder
# source-udp-forwarder-cs2:
# image: startersclan/source-udp-forwarder:latest
# environment:
# - LISTEN_ADDR=:26999
# - UDP_FORWARD_ADDR=daemon:27500
# - FORWARD_PROXY_KEY=somedaemonsecret # The daemon's proxy_key secret
# - FORWARD_GAMESERVER_IP=10.5.0.101 # The gameserver's IP as registered in the HLStatsX:CE database
# - FORWARD_GAMESERVER_PORT=27016 # The gameserver's IP as registered in the HLStatsX:CE database
# - LOG_LEVEL=INFO
# - LOG_FORMAT=txt
# networks:
# - default
# depends_on:
# - daemon
# 3. HLStatsX:CE perl daemon accepts the gameserver logs. Gameserver Logs are parsed and stats are recorded
# The daemon's proxy_key secret can only be setup in the HLStatsX:CE Web Admin Panel Settings under 'Proxy Settings' section
daemon:
image: startersclan/hlstatsx-community-edition:1.11.3-daemon
ports:
- 27500:27500/udp # For external servers to send logs to the daemon
networks:
default:
ipv4_address: 10.5.0.50 # Static IP
depends_on:
- db
command:
- --ip=0.0.0.0
- --port=27500
- --db-host=db:3306
- --db-name=hlstatsxce
- --db-username=hlstatsxce
- --db-password=hlstatsxce
- --nodns-resolveip
- --debug
# - --debug
# - --help
# Cron - awards
awards:
image: startersclan/hlstatsx-community-edition:1.11.3-daemon
stop_signal: SIGKILL
entrypoint:
- /bin/sh
command:
- -c
- |
set -eu
echo "Creating /awards.sh"
cat - > /awards.sh <<'EOF'
#!/bin/sh
set -eu
cd /scripts
perl hlstats-awards.pl --db-host=db:3306 --db-name=hlstatsxce --db-username=hlstatsxce --db-password=hlstatsxce #--help
EOF
chmod +x /awards.sh
# Run at 00:00 daily. To customize your cron schedule, use https://crontab.guru
echo "Creating crontab"
crontab - <<'EOF'
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
0 0 * * * /awards.sh > /proc/1/fd/1 2>/proc/1/fd/2
EOF
crontab -l
echo "Running cron"
cron -f
# 4. HLStatsX:CE DB
db:
image: mysql:5.7
environment:
- MYSQL_ROOT_PASSWORD=root # Username 'root', password 'root'
- MYSQL_USER=hlstatsxce
- MYSQL_PASSWORD=hlstatsxce
- MYSQL_DATABASE=hlstatsxce
volumes:
- db-volume:/var/lib/mysql
- ./src/sql/install.sql:/docker-entrypoint-initdb.d/install.sql:ro # This seeds the DB only on the first time
networks:
- default
# 5. HLStatsX:CE web
# Available at http://localhost:8081, or https://web.example.com
# Admin Panel username: admin, password: 123456
web:
image: startersclan/hlstatsx-community-edition:1.11.3-web
labels:
- "traefik.enable=true"
- "traefik.docker.network=hlstatsx-community-edition_traefik-network"
# traefik v2
# http
- "traefik.http.routers.${COMPOSE_PROJECT_NAME?err}-web-http.entrypoints=web"
- "traefik.http.routers.${COMPOSE_PROJECT_NAME?err}-web-http.rule=Host(`web.example.com`)"
- "traefik.http.routers.${COMPOSE_PROJECT_NAME?err}-web-http.middlewares=hlstatsx-community-edition-web-http-myRedirectScheme" # Redirect http to https
- "traefik.http.middlewares.${COMPOSE_PROJECT_NAME?err}-web-http-myRedirectScheme.redirectScheme.scheme=https" # Redirect http to https
# https
- "traefik.http.routers.${COMPOSE_PROJECT_NAME?err}-web.entrypoints=websecure"
- "traefik.http.routers.${COMPOSE_PROJECT_NAME?err}-web.tls="
- "traefik.http.routers.${COMPOSE_PROJECT_NAME?err}-web.rule=Host(`web.example.com`)"
- "traefik.http.services.${COMPOSE_PROJECT_NAME?err}-web.loadbalancer.server.port=80"
volumes:
- games-volume:/web/hlstatsimg/games # Stateful games volume, which also contains heatmaps
environment:
- DB_ADDR=db
- DB_NAME=hlstatsxce
- DB_USER=hlstatsxce
- DB_PASS=hlstatsxce
- DB_DEBUG=0
ports:
- 127.0.0.1:8081:80
- 9000
networks:
- traefik-network
- default
depends_on:
- init-container
# Cron - Heatmaps
heatmaps:
image: startersclan/hlstatsx-community-edition:1.11.3-web
volumes:
- games-volume:/web/hlstatsimg/games # Stateful games volume, which also contains heatmaps
environment:
- DB_HOST=db
- DB_NAME=hlstatsxce
- DB_USER=hlstatsxce
- DB_PASS=hlstatsxce
- HLXCE_WEB=/web
- HUD_URL=http://www.hlxcommunity.com
- OUTPUT_SIZE=medium
- DEBUG=1
depends_on:
- init-container
- web
working_dir: /heatmaps
stop_signal: SIGKILL
entrypoint:
- /bin/sh
command:
- -c
- |
set -eu
# Run at 00:00 daily. To customize your cron schedule, use https://crontab.guru
echo "Creating crontab"
crontab - <<'EOF'
0 0 * * * php /heatmaps/generate.php > /proc/1/fd/1 2>/proc/1/fd/2
EOF
crontab -l
echo "Running crond"
exec crond -f
# PHPMyAdmin to manage DB
# Available at http://localhost:8083, or https://phpmyadmin.example.com
phpmyadmin:
image: phpmyadmin:5.2
labels:
- "traefik.enable=true"
- "traefik.docker.network=hlstatsx-community-edition_traefik-network"
# traefik v2
# http
- "traefik.http.routers.${COMPOSE_PROJECT_NAME?err}-phpmyadmin-http.entrypoints=web"
- "traefik.http.routers.${COMPOSE_PROJECT_NAME?err}-phpmyadmin-http.rule=Host(`phpmyadmin.example.com`)"
- "traefik.http.routers.${COMPOSE_PROJECT_NAME?err}-phpmyadmin-http.middlewares=hlstatsx-community-edition-phpmyadmin-http-myRedirectScheme" # Redirect http to https
- "traefik.http.middlewares.${COMPOSE_PROJECT_NAME?err}-phpmyadmin-http-myRedirectScheme.redirectScheme.scheme=https" # Redirect http to https
# https
- "traefik.http.routers.${COMPOSE_PROJECT_NAME?err}-phpmyadmin.entrypoints=websecure"
- "traefik.http.routers.${COMPOSE_PROJECT_NAME?err}-phpmyadmin.tls="
- "traefik.http.routers.${COMPOSE_PROJECT_NAME?err}-phpmyadmin.rule=Host(`phpmyadmin.example.com`)"
- "traefik.http.services.${COMPOSE_PROJECT_NAME?err}-phpmyadmin.loadbalancer.server.port=80"
environment:
- PMA_HOST=db
ports:
- 127.0.0.1:8083:80
networks:
- traefik-network
- default
# Init container to set permissions in mounted folders and volumes
init-container:
image: alpine:latest
volumes:
- db-volume:/var/lib/mysql
networks:
- default
entrypoint:
- /bin/sh
command:
- -c
- |
set -eu
echo "Granting db write permissions"
chown -R 999:999 /var/lib/mysql
# The reverse proxy for our web containers
# See https://github.com/traefik/traefik/tree/v2.7/docs/content/user-guides/docker-compose for some examples for enabling HTTPS using ACME
# You will need a domain name. E.g. 'example.com'
traefik:
image: traefik:v2.10
volumes:
# Allow traefik to listen to the Docker events
- /var/run/docker.sock:/var/run/docker.sock:ro
- traefik-acme-volume:/letsencrypt
ports:
- 80:80
- 443:443
networks:
- traefik-public-network
- traefik-network
restart: unless-stopped
command:
- --global.checknewversion=false
- --global.sendanonymoususage=false
# - --log.level=DEBUG
- --providers.docker=true
- --providers.docker.exposedbydefault=false
- --entrypoints.web.address=:80
- --entrypoints.websecure.address=:443
- --certificatesresolvers.myresolver.acme.dnschallenge=true
- --certificatesresolvers.myresolver.acme.dnschallenge.provider=ovh
# - --certificatesresolvers.myresolver.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory
- --certificatesresolvers.myresolver.acme.email=postmaster@example.com
- --certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json
networks:
default:
driver: bridge
ipam:
config:
- subnet: 10.5.0.0/16
gateway: 10.5.0.1
traefik-public-network:
traefik-network:
internal: true
volumes:
db-volume:
games-volume:
traefik-acme-volume: