-
-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathdocker-compose.base.yml
More file actions
238 lines (227 loc) · 6.12 KB
/
docker-compose.base.yml
File metadata and controls
238 lines (227 loc) · 6.12 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
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
version: '3.8'
# Base services for docker-compose modular setup
services:
nginx-proxy:
image: jwilder/nginx-proxy
restart: always
ports:
- "80:80"
- "443:443"
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
- ./certs:/etc/nginx/certs
- ./vhost.d:/etc/nginx/vhost.d
- ./html:/usr/share/nginx/html
labels:
- com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy
networks:
- proxy-network
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost/"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
letsencrypt:
image: jrcs/letsencrypt-nginx-proxy-companion
restart: always
volumes:
- ./certs:/etc/nginx/certs:rw
- ./vhost.d:/etc/nginx/vhost.d:rw
- ./html:/usr/share/nginx/html:rw
- /var/run/docker.sock:/var/run/docker.sock:ro
environment:
- NGINX_PROXY_CONTAINER=nginx-proxy
networks:
- proxy-network
depends_on:
nginx-proxy:
condition: service_healthy
redis:
image: redis:7-alpine
restart: always
command: redis-server --appendonly yes --requirepass ${REDIS_PASSWORD:-changeme}
ports:
- "6379:6379"
volumes:
- redis-data:/data
networks:
- proxy-network
healthcheck:
test: ["CMD", "redis-cli", "--raw", "incr", "ping"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
mysql:
image: mariadb:11.2
restart: always
environment:
MYSQL_ROOT_PASSWORD_FILE: /run/secrets/db_root_password
MYSQL_DATABASE: ${DB_DATABASE:-myapp}
MYSQL_USER: ${DB_USERNAME:-myapp}
MYSQL_PASSWORD_FILE: /run/secrets/db_password
ports:
- "3306:3306"
volumes:
- mysql-data:/var/lib/mysql
- ./docker/mysql/custom.cnf:/etc/mysql/conf.d/custom.cnf:ro
secrets:
- db_root_password
- db_password
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p$$(cat /run/secrets/db_root_password)"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
networks:
- proxy-network
# PostgreSQL (optional) - Use with: docker-compose --profile postgresql up
postgresql:
image: postgres:16-alpine
restart: always
environment:
POSTGRES_DB: ${DB_DATABASE:-myapp}
POSTGRES_USER: ${DB_USERNAME:-myapp}
POSTGRES_PASSWORD_FILE: /run/secrets/db_password
ports:
- "5432:5432"
volumes:
- postgresql-data:/var/lib/postgresql/data
secrets:
- db_password
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${DB_USERNAME:-myapp}"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
networks:
- proxy-network
profiles:
- postgresql
control-panel:
build:
context: .
dockerfile: Dockerfile
args:
- BUILD_DATE=${BUILD_DATE:-$(date -u +'%Y-%m-%dT%H:%M:%SZ')}
- VCS_REF=${VCS_REF:-$(git rev-parse --short HEAD)}
restart: always
environment:
- APP_ENV=${APP_ENV:-production}
- APP_KEY=${APP_KEY}
- APP_DEBUG=${APP_DEBUG:-false}
- DB_CONNECTION=${DB_CONNECTION:-mysql}
- DB_HOST=${DB_HOST:-mysql}
- DB_DATABASE=${DB_DATABASE:-myapp}
- DB_USERNAME=${DB_USERNAME:-myapp}
- DB_PASSWORD_FILE=/run/secrets/db_password
- REDIS_HOST=redis
- REDIS_PASSWORD=${REDIS_PASSWORD:-changeme}
- VIRTUAL_HOST=${CONTROL_PANEL_DOMAIN}
- LETSENCRYPT_HOST=${CONTROL_PANEL_DOMAIN}
- LETSENCRYPT_EMAIL=${LETSENCRYPT_EMAIL}
volumes:
- app-storage:/var/www/html/storage
- app-cache:/var/www/html/bootstrap/cache
depends_on:
mysql:
condition: service_healthy
redis:
condition: service_healthy
secrets:
- db_password
networks:
- proxy-network
healthcheck:
test: ["CMD", "php", "-v"]
interval: 30s
timeout: 10s
retries: 3
start_period: 60s
# Queue worker for background jobs
queue-worker:
build:
context: .
dockerfile: Dockerfile
restart: always
command: php artisan queue:work --sleep=3 --tries=3 --max-time=3600
environment:
- APP_ENV=${APP_ENV:-production}
- APP_KEY=${APP_KEY}
- DB_CONNECTION=${DB_CONNECTION:-mysql}
- DB_HOST=${DB_HOST:-mysql}
- DB_DATABASE=${DB_DATABASE:-myapp}
- DB_USERNAME=${DB_USERNAME:-myapp}
- DB_PASSWORD_FILE=/run/secrets/db_password
- REDIS_HOST=redis
- REDIS_PASSWORD=${REDIS_PASSWORD:-changeme}
volumes:
- app-storage:/var/www/html/storage
depends_on:
mysql:
condition: service_healthy
redis:
condition: service_healthy
control-panel:
condition: service_started
secrets:
- db_password
networks:
- proxy-network
healthcheck:
test: ["CMD", "ps", "aux", "|", "grep", "queue:work"]
interval: 60s
timeout: 10s
retries: 3
# Scheduler for cron jobs
scheduler:
build:
context: .
dockerfile: Dockerfile
restart: always
command: sh -c "while true; do php artisan schedule:run --verbose --no-interaction & sleep 60; done"
environment:
- APP_ENV=${APP_ENV:-production}
- APP_KEY=${APP_KEY}
- DB_CONNECTION=${DB_CONNECTION:-mysql}
- DB_HOST=${DB_HOST:-mysql}
- DB_DATABASE=${DB_DATABASE:-myapp}
- DB_USERNAME=${DB_USERNAME:-myapp}
- DB_PASSWORD_FILE=/run/secrets/db_password
- REDIS_HOST=redis
- REDIS_PASSWORD=${REDIS_PASSWORD:-changeme}
volumes:
- app-storage:/var/www/html/storage
depends_on:
mysql:
condition: service_healthy
redis:
condition: service_healthy
control-panel:
condition: service_started
secrets:
- db_password
networks:
- proxy-network
volumes:
mysql-data:
driver: local
postgresql-data:
driver: local
redis-data:
driver: local
app-storage:
driver: local
app-cache:
driver: local
secrets:
db_root_password:
file: ./secrets/db_root_password.txt
db_password:
file: ./secrets/db_password.txt
networks:
proxy-network:
driver: bridge