-
-
Notifications
You must be signed in to change notification settings - Fork 136
/
Copy pathdocker-lnmp.yml
322 lines (306 loc) · 9.5 KB
/
docker-lnmp.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
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
#
# @link https://www.ruanyifeng.com/blog/2016/07/yaml.html
#
# @link https://docs.docker.com/compose/
# @link https://docs.docker.com/compose/compose-file/#extension-fields
# @link https://github.com/docker-library/docs
#
x-common-labels:
&common-labels
labels:
- ${LNMP_DOMAIN:-com.khs1994.lnmp}=true
- ${LNMP_DOMAIN:-com.khs1994.lnmp}.app.env=development
x-common:
&common
restart: ${LNMP_RESTART:-always}
env_file: ./scripts/cli/timezone.env
networks:
- backend
read_only: ${LNMP_ROOT_FILESYSTEM_READ_ONLY:-false}
# dns:
# - ${DNS:-114.114.114.114}
x-tmpfs:
&tmpfs
type: tmpfs
target: /run
# tmpfs:
# size: 1000
services:
mysql:
<< : [*common,*common-labels]
image: "${LNMP_LIBRARY_NS:-library}/mysql:${LNMP_MYSQL_VERSION:-8.0.33}"
environment:
# @link https://github.com/docker-library/docs/tree/master/mysql#environment-variables
# @link https://dev.mysql.com/doc/refman/8.0/en/environment-variables.html
# MYSQL_ROOT_PASSWORD_FILE: /run/secrets/db_root_password
MYSQL_ROOT_PASSWORD: ${LNMP_MYSQL_ROOT_PASSWORD:-mytest}
MYSQL_DATABASE: ${LNMP_MYSQL_DATABASE:-test}
# MYSQL_USER:
# MYSQL_PASSWORD:
ports:
- "${LNMP_MYSQL_PORT:-127.0.0.1:3306}:3306"
- "${LNMP_MYSQL_PORT_X:-127.0.0.1:33060}:33060"
volumes:
- ./config/mysql/conf.d/my.cnf:/etc/mysql/conf.d/my.cnf
# @link https://github.com/docker-library/docs/tree/master/mysql#initializing-a-fresh-instance
- ./scripts/backup/init:/docker-entrypoint-initdb.d:ro
- type: volume
source: mysql-data
target: ${LNMP_MYSQL_DATA:-/var/lib/mysql}
- ./log/mysql:/var/log/mysql
- ./scripts/backup/mysql:/backup
- type: tmpfs
target: /var/run/mysqld
command:
- mysqld
- --character-set-server=utf8mb4
- --default-authentication-plugin=mysql_native_password
secrets:
- db_root_password
# - source: mysql_conf
# target: /etc/mysql/conf.d/my.cnf
# uid: "999"
# gid: "999"
# mode: 0644
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-p${LNMP_MYSQL_ROOT_PASSWORD:-mytest}"]
retries: 3
timeout: 5s
redis:
<< : [*common,*common-labels]
image: "${LNMP_LIBRARY_NS:-library}/redis:${LNMP_REDIS_VERSION:-7.0.0}-alpine"
ports:
- "${LNMP_REDIS_PORT:-127.0.0.1:6379}:6379"
volumes:
- ./config/redis/redis.conf:/redis.conf:ro
# - redis-data:/data
- type: volume
source: redis-data
target: /data
volume:
nocopy: true
- ./log/redis:/var/log/redis
- << : *tmpfs
# set config by command
command: [
"redis-server",
"/redis.conf",
"--daemonize no",
"--logfile /var/log/redis/redis.log",
"--bind 0.0.0.0",
"--appendonly yes",
# "--save \"\"",
"--aof-use-rdb-preamble yes"
]
healthcheck:
test: ["CMD","redis-cli","ping"]
retries: 3
timeout: 5s
memcached:
<< : [*common,*common-labels]
image: ${LNMP_LIBRARY_NS:-library}/memcached:${LNMP_MEMCACHED_VERSION:-1.6.15}-alpine
ports:
- "${LNMP_MEMCACHED_PORT:-127.0.0.1:11211}:11211"
volumes:
- type: volume
source: zoneinfo-data
target: /usr/share/zoneinfo
volume:
nocopy: true
- << : *tmpfs
php7:
&php7
<< : [*common,*common-labels]
image: "${LNMP_DOCKER_IMAGE_PREFIX:-khs1994}/php:${LNMP_PHP7_VERSION:-7.4.33}-fpm-alpine"
volumes:
- &bind_app ${APP_ROOT:-./app}:${LNMP_PHP_PATH:-/app}
# fpm config
- ./config/php/zz-docker.conf:/usr/local/etc/php-fpm.d/zz-docker.conf:ro
# php.ini
- ./config/php/php.ini:/usr/local/etc/php/php.ini:ro
# php.ini override
- ./config/php/docker-php.ini:/usr/local/etc/php/conf.d/docker-php.ini:ro
# log,etc
- ./log/php:/var/log/php
# supervisord
- ./log/supervisord.log:/var/log/supervisord.log
- ./log/supervisord:/var/log/supervisord
# s6
- ./config/s6/s6-overlay/scripts:/etc/s6-overlay/scripts
- ./config/s6/s6-overlay/${S6_RC_D:-s6-rc.d}:/etc/s6-overlay/s6-rc.d
- ./config/crontabs/root:/etc/crontabs/root.s6
- php7-var-log:/var/log
- type: volume
source: zoneinfo-data
target: /usr/share/zoneinfo
volume:
nocopy: false
networks:
- frontend
- backend
# frontend:
# aliases:
# - php
# backend:
# aliases:
# - php
tmpfs: /run:exec
expose:
- "9000"
# command: php-fpm -R -F
# command: php-fpm -F
environment:
- &lnmp_version LNMP_VERSION=${LNMP_VERSION:-v23.11} x86_64 With Pull Docker Image
- APP_ENV=${APP_ENV:-development}
- LNMP_XDEBUG_REMOTE_HOST=${LNMP_XDEBUG_REMOTE_HOST:-192.168.199.100}
- LNMP_XDEBUG_REMOTE_PORT=${LNMP_XDEBUG_REMOTE_PORT:-9003}
- LNMP_OPCACHE_ENABLE=${LNMP_OPCACHE_ENABLE:-1}
- PATH=/command:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
# - PHP_INI_SCAN_DIR=:/usr/local/etc/php/conf.d
php8:
&php8
<< : [*common,*common-labels]
image: "${LNMP_DOCKER_IMAGE_PREFIX:-khs1994}/php:${LNMP_PHP8_VERSION:-8.3.12}-fpm-alpine"
volumes:
- *bind_app
# - ${APP_ROOT:-./app}:${LNMP_PHP_PATH:-/app}
# fpm config
- ./config/php8/zz-docker.conf:/usr/local/etc/php-fpm.d/zz-docker.conf:ro
# php.ini
- ./config/php8/php.ini:/usr/local/etc/php/php.ini:ro
# php.ini override
- ./config/php8/docker-php.ini:/usr/local/etc/php/conf.d/docker-php.ini:ro
# log,etc
- ./log/php8:/var/log/php
# supervisord
# - ./log/supervisord.log:/var/log/supervisord.log
# - ./log/supervisord:/var/log/supervisord
# s6
- ./config/s6/s6-overlay/scripts:/etc/s6-overlay/scripts
- ./config/s6/s6-overlay/${S6_RC_D:-s6-rc.d}:/etc/s6-overlay/s6-rc.d
- ./config/crontabs/root:/etc/crontabs/root.s6
- php8-var-log:/var/log
- type: volume
source: zoneinfo-data
target: /usr/share/zoneinfo
volume:
nocopy: false
networks:
# - frontend
# - backend
frontend:
aliases:
- php
backend:
aliases:
- php
tmpfs: /run:exec
expose:
- "9000"
# command: php-fpm -R -F
# command: php-fpm -F
environment:
- *lnmp_version
- APP_ENV=${APP_ENV:-development}
- LNMP_XDEBUG_REMOTE_HOST=${LNMP_XDEBUG_REMOTE_HOST:-192.168.199.100}
- LNMP_XDEBUG_REMOTE_PORT=${LNMP_XDEBUG_REMOTE_PORT:-9003}
- LNMP_OPCACHE_ENABLE=${LNMP_OPCACHE_ENABLE:-1}
- PATH=/command:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
# - XDEBUG_MODE
composer:
<< : [*common,*common-labels]
restart: "no"
image: "${LNMP_DOCKER_IMAGE_PREFIX:-khs1994}/php:${LNMP_PHP_VERSION:-8.3.12}-composer-alpine"
volumes:
- *bind_app
# - ${APP_ROOT:-./app}:${LNMP_PHP_PATH:-/app}
- type: volume
source: composer-cache-data
target: /tmp/composer/cache
- ./config/composer/config.json:/tmp/composer/config.json
# - ./config/composer/auth.json:/tmp/composer/auth.json
# https://docs.docker.com/config/containers/multi-service_container/
# http://supervisord.org/running.html
supervisord:
<< : *php7
networks:
- backend
image: "${LNMP_DOCKER_IMAGE_PREFIX:-khs1994}/php:${LNMP_PHP_VERSION:-7.4.33}-supervisord-alpine"
secrets:
- source: supervisord_ini
target: /etc/supervisor.d/supervisord.ini
command: ["/usr/bin/supervisord","-n"]
expose:
- "9003"
phpmyadmin:
<< : [*common,*common-labels]
image: ${LNMP_LIBRARY_NS:-library}/phpmyadmin:${LNMP_PHPMYADMIN_VERSION:-5.2.0}
environment:
- PMA_HOST=mysql
ports:
- ${LNMP_PHPMYADMIN_PORT:-127.0.0.1:8080}:80
volumes:
- type: volume
source: phpmyadmin-data
target: /sessions
- << : *tmpfs
networks:
- backend
- frontend
healthcheck:
test: ["CMD","curl","-sf","127.0.0.1:80"]
# test: ["CMD-SHELL", "curl -f http://localhost || exit 1"]
nginx:
<< : [*common,*common-labels]
image: "${LNMP_LIBRARY_NS:-library}/nginx:${LNMP_NGINX_VERSION:-1.27.0}-alpine"
ports:
- "${LNMP_NGINX_HTTPS_PORT:-0.0.0.0:443}:443/udp"
- "${LNMP_NGINX_HTTPS_PORT:-0.0.0.0:443}:443/tcp"
- "${LNMP_NGINX_HTTP_PORT:-0.0.0.0:80}:80"
volumes:
# - ./config/nginx:/etc/nginx/conf.d:ro
- type: bind
source: ./config/${LNMP_NGINX_CONF_D:-nginx}
target: /etc/nginx/conf.d
- *bind_app
# - ${APP_ROOT:-./app}:${LNMP_PHP_PATH:-/app}
- ./config/etc/nginx/${LNMP_NGINX_CONF:-nginx.conf}:/etc/nginx/nginx.conf:ro
- ./log/nginx:/var/log/nginx
- << : *tmpfs
working_dir: /app
networks:
- frontend
# depends_on:
# - php8
healthcheck:
test: ["CMD","nginx","-t"]
networks:
frontend:
<< : *common-labels
backend:
<< : *common-labels
volumes:
mysql-data:
<< : *common-labels
redis-data:
<< : *common-labels
zoneinfo-data:
<< : *common-labels
phpmyadmin-data:
<< : *common-labels
composer-cache-data:
<< : *common-labels
php8-var-log:
<< : *common-labels
php7-var-log:
<< : *common-labels
secrets:
db_root_password:
<< : *common-labels
file: ./secrets/${LNMP_DB_ROOT_PASSWORD_PATH:-db_root_password.txt}
supervisord_ini:
<< : *common-labels
file: ./config/supervisord/supervisord.ini
# mysql_conf:
# << : *common-labels
# file: ./config/mysql/conf.d/my.cnf