forked from smrealms/smr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.yml
243 lines (218 loc) · 7.19 KB
/
docker-compose.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
version: '3.7'
networks:
frontend:
name: frontend
external: false
backend:
name: backend
external: false
# Builds a local smr image for use in other services
x-smr-builder: &smr-builder
build:
context: .
args:
- NO_DEV
image: local/smr
# Base configuration for `smr` (production) and `smr-dev` (testing).
x-smr-common: &smr-common
<<: *smr-builder
container_name: ${SMR_HOST}
networks:
- frontend
- backend
labels:
- "traefik.enable=true"
- "traefik.http.routers.${SMR_HOST}.rule=${SMR_RULE:-PathPrefix(`/`)}"
depends_on:
- mysql
- smtp
# Base configuration for the SMR command line tools
x-smr-cli: &smr-cli
<<: *smr-builder
networks:
- backend
depends_on:
- mysql
- smtp
volumes:
- ./config:/smr/config:ro
# Mount the source code instead of copying it.
- ./src:/smr/src:ro
# Base configuration for SMR testing tools
x-smr-test: &smr-test
<<: *smr-cli
# Allow the process to be interruptible with SIGINT.
# Note that this may corrupt the test database and require a reset.
# (see https://github.com/docker-library/php/issues/505)
init: true
volumes:
- ./config/config.specific.sample.php:/smr/config/config.specific.php:ro
- ./test/env:/smr/config/env:ro
- ./phpunit.xml:/smr/phpunit.xml:ro
- ./phpstan.neon.dist:/smr/phpstan.neon.dist:ro
- ./phpcs.xml:/smr/phpcs.xml:ro
# Mount the source code instead of copying it.
- ./src:/smr/src:rw
- ./test:/smr/test:rw
depends_on:
- mysql-test
x-mysql-common: &mysql-common
image: mysql:8.0
container_name: ${MYSQL_HOST}
networks:
- backend
# By using the default image, we must expose the secrets in
# the runtime environment (because we can't specify build args).
environment:
- MYSQL_ROOT_PASSWORD
- MYSQL_USER
- MYSQL_PASSWORD
- MYSQL_DATABASE
# The mysql:5.7+ docker default sql mode uses STRICT_TRANS_TABLES,
# which is incompatible with the way the SMR database is used.
# Therefore, we override CMD to omit this sql mode.
command: [ "mysqld", "--sql-mode=NO_ENGINE_SUBSTITUTION",
"--character-set-server=utf8",
"--collation-server=utf8_general_ci" ]
services:
smr:
<<: *smr-common
volumes:
- ./vol_upload:/smr/src/htdocs/upload:rw
- ./config:/smr/config:ro
environment:
- XDEBUG_MODE
smr-dev:
<<: *smr-common
volumes:
- ./vol_upload:/smr/src/htdocs/upload:rw
- ./config:/smr/config:ro
# Mount the source code instead of copying it.
- ./src:/smr/src:ro
# Directory for Xdebug profiler output
- ./vol_xdebug:/tmp/xdebug:rw
environment:
- XDEBUG_MODE
- DISABLE_PHPDI_COMPILATION=true
smtp:
image: mwader/postfix-relay
networks:
- backend
environment:
- POSTFIX_myhostname=hostname.local
- OPENDKIM_DOMAINS=smrealms.de=key1
volumes:
- ./opendkim:/etc/opendkim/keys/smrealms.de:rw
flyway: &flyway-common
image: flyway/flyway:latest-alpine
# Allow retries in case the mysql service is still spinning up
command: -connectRetries=20 -url=jdbc:mysql://${MYSQL_HOST}/${MYSQL_DATABASE}?allowPublicKeyRetrieval=true&useSSL=false -user=${MYSQL_USER} -password=${MYSQL_PASSWORD} migrate
networks:
- backend
depends_on:
- mysql
volumes:
- ./db/patches:/flyway/sql:ro
flyway-test:
<<: *flyway-common
depends_on:
- mysql-test
mysql:
<<: *mysql-common
volumes:
- ./vol_db:/var/lib/mysql:rw
# MySQL container with no volumes mounted for testing
mysql-test:
<<: *mysql-common
phpunit:
<<: *smr-test
entrypoint: vendor/bin/phpunit
environment:
- XDEBUG_MODE=coverage
phpstan:
<<: *smr-test
entrypoint: vendor/bin/phpstan --memory-limit=4G --ansi analyse -v
phpcs:
<<: *smr-test
entrypoint: vendor/bin/phpcs --report-code --report-source
phpcbf:
<<: *smr-test
entrypoint: vendor/bin/phpcbf
pma:
image: phpmyadmin/phpmyadmin
networks:
- frontend
- backend
environment:
PMA_HOST: ${MYSQL_HOST}
PMA_ABSOLUTE_URI: /pma/
labels:
- "traefik.enable=true"
- "traefik.http.routers.pma-${MYSQL_HOST}.rule=${SMR_RULE:-PathPrefix(`/`)} && PathPrefix(`/pma`)"
- "traefik.http.routers.pma-${MYSQL_HOST}.middlewares=slash-then-strip@file"
depends_on:
- mysql
discord:
init: true
command: php src/tools/discord/bot.php
<<: *smr-cli
irc:
command: php src/tools/irc/irc.php
<<: *smr-cli
npc:
command: php src/tools/npc/npc.php
<<: *smr-cli
traefik:
image: traefik:2.8
networks:
- frontend
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./traefik:/etc/traefik:ro
labels:
- "traefik.enable=true"
- "traefik.http.routers.traefik.rule=PathPrefix(`/api`) || PathPrefix(`/dashboard`)"
- "traefik.http.routers.traefik.service=api@internal"
- "traefik.http.routers.traefik.middlewares=add-slash@file"
ports:
- "80:80"
- "443:443"
# Generate rich API documentation of the SMR source code.
api-docs:
build:
context: .
dockerfile: ./api-docs/Dockerfile
networks:
- frontend
labels:
- "traefik.enable=true"
- "traefik.http.routers.api-docs.rule=PathPrefix(`/docs`)"
- "traefik.http.routers.api-docs.middlewares=slash-then-strip@file"
# Web interface for managing Docker services
portainer:
image: portainer/portainer-ce
networks:
- frontend
labels:
- "traefik.enable=true"
- "traefik.http.routers.portainer.rule=PathPrefix(`/docker`)"
- "traefik.http.routers.portainer.middlewares=slash-then-strip@file"
- "traefik.http.services.portainer.loadbalancer.server.port=9000"
command: -H unix:///var/run/docker.sock
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./vol_portainer:/data:rw
# Web interface to display Xdebug profiler results
webgrind:
image: jokkedk/webgrind
networks:
- frontend
labels:
- "traefik.enable=true"
- "traefik.http.routers.webgrind.rule=PathPrefix(`/webgrind`)"
- "traefik.http.routers.webgrind.middlewares=slash-then-strip@file"
volumes:
# Webgrind looks for Xdebug profiler files in /tmp by default
- ./vol_xdebug:/tmp:rw
# Files mapped under /host will be available for code lookup
- ./src:/host/smr/src:ro