Repository navigation
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
201 lines (192 loc) · 5.73 KB
/
Copy pathdocker-compose.yml
File metadata and controls
201 lines (192 loc) · 5.73 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
# Production stack for FaqHub Backend (Dokploy)
#
# Host bind mounts:
# ${FAQHUB_STATIC_PATH:-/opt/faqhub}/storage -> storage/app/public
# ${SITEMAPS_HOST_PATH:-/opt/faqhub/sitemaps} -> public/sitemaps
#
# Networks:
# faqhub private bridge — app, workers, MySQL, Redis
# dokploy-network external Dokploy/Traefik network (must already exist)
#
# Dokploy domains (UI) target app:8000 (API) and reverb:8080 (WebSocket).
# Those two services are dual-homed. traefik.docker.network pins Traefik to
# dokploy-network so it does not pick the private bridge and 504.
# mysql, redis, queue, and scheduler stay on faqhub only.
# One image for app, queue, scheduler, and reverb. Only app builds it;
# the other roles reuse the tag so Compose does not compile four copies.
x-app-common: &app-common
image: faqhub-backend:${IMAGE_TAG:-latest}
restart: unless-stopped
env_file:
- .env
environment: &app-env
APP_ENV: ${APP_ENV:-production}
APP_DEBUG: ${APP_DEBUG:-false}
APP_URL: ${APP_URL:-http://localhost:8000}
DB_CONNECTION: ${DB_CONNECTION:-app}
# Unqualified mysql/redis on dokploy-network resolve to another stack.
DB_HOST: faqhub-mysql
DB_PORT: 3306
DB_DATABASE: ${DB_DATABASE:-faqhub}
DB_USERNAME: ${DB_USERNAME:-faqhub}
DB_PASSWORD: ${DB_PASSWORD:-faqhub}
REDIS_HOST: faqhub-redis
REDIS_PORT: 6379
REDIS_PASSWORD: ${REDIS_PASSWORD:-}
CACHE_STORE: ${CACHE_STORE:-redis}
QUEUE_CONNECTION: ${QUEUE_CONNECTION:-redis}
SESSION_DRIVER: ${SESSION_DRIVER:-redis}
BROADCAST_CONNECTION: ${BROADCAST_CONNECTION:-reverb}
REVERB_SERVER_HOST: 0.0.0.0
REVERB_SERVER_PORT: 8080
REVERB_HOST: ${REVERB_HOST:-localhost}
REVERB_PORT: ${REVERB_PORT:-8080}
REVERB_SCHEME: ${REVERB_SCHEME:-http}
REVERB_APP_ID: ${REVERB_APP_ID:-faqhub}
REVERB_APP_KEY: ${REVERB_APP_KEY:-faqhub-key}
REVERB_APP_SECRET: ${REVERB_APP_SECRET:-faqhub-secret}
LOG_CHANNEL: stderr
volumes:
- ${FAQHUB_STATIC_PATH:-/opt/faqhub}/storage:/var/www/html/storage/app/public
- ${SITEMAPS_HOST_PATH}:/var/www/html/public/sitemaps
networks:
- faqhub
depends_on:
mysql:
condition: service_healthy
redis:
condition: service_healthy
services:
app:
<<: *app-common
build:
context: .
dockerfile: Dockerfile
target: app
environment:
<<: *app-env
CONTAINER_ROLE: app
RUN_MIGRATIONS: ${RUN_MIGRATIONS:-true}
CACHE_CONFIG: ${CACHE_CONFIG:-true}
RUN_STORAGE_LINK: ${RUN_STORAGE_LINK:-true}
networks:
- faqhub
- dokploy-network
labels:
- traefik.docker.network=${DOKPLOY_NETWORK:-dokploy-network}
expose:
- "8000"
command: ["php", "artisan", "serve", "--host=0.0.0.0", "--port=8000"]
healthcheck:
test: ["CMD", "php", "-r", "exit(@fsockopen('127.0.0.1', 8000) ? 0 : 1);"]
interval: 30s
timeout: 5s
retries: 5
start_period: 60s
queue:
<<: *app-common
environment:
<<: *app-env
CONTAINER_ROLE: queue
RUN_MIGRATIONS: "false"
CACHE_CONFIG: "false"
RUN_STORAGE_LINK: ${RUN_STORAGE_LINK:-true}
healthcheck:
disable: true
scheduler:
# The scheduler loop runs sitemap:generate according to routes/console.php.
<<: *app-common
environment:
<<: *app-env
CONTAINER_ROLE: scheduler
RUN_MIGRATIONS: "false"
CACHE_CONFIG: "false"
RUN_STORAGE_LINK: ${RUN_STORAGE_LINK:-true}
healthcheck:
disable: true
reverb:
<<: *app-common
environment:
<<: *app-env
CONTAINER_ROLE: reverb
RUN_MIGRATIONS: "false"
CACHE_CONFIG: "false"
RUN_STORAGE_LINK: ${RUN_STORAGE_LINK:-true}
networks:
- faqhub
- dokploy-network
labels:
- traefik.docker.network=${DOKPLOY_NETWORK:-dokploy-network}
expose:
- "8080"
healthcheck:
test: ["CMD", "php", "-r", "exit(@fsockopen('127.0.0.1', 8080) ? 0 : 1);"]
interval: 30s
timeout: 5s
retries: 5
start_period: 30s
mysql:
image: mysql:8.4
restart: unless-stopped
command:
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_unicode_ci
environment:
MYSQL_DATABASE: ${DB_DATABASE:-faqhub}
MYSQL_USER: ${DB_USERNAME:-faqhub}
MYSQL_PASSWORD: ${DB_PASSWORD:-faqhub}
MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD:-rootsecret}
expose:
- "3306"
volumes:
- mysql_data:/var/lib/mysql
networks:
faqhub:
aliases:
- faqhub-mysql
healthcheck:
test: ["CMD-SHELL", "mysqladmin ping -h 127.0.0.1 -uroot -p\"$$MYSQL_ROOT_PASSWORD\" || exit 1"]
interval: 10s
timeout: 5s
retries: 20
start_period: 60s
redis:
image: redis:7-alpine
restart: unless-stopped
command:
- /bin/sh
- -c
- |
if [ -n "$$REDIS_PASSWORD" ] && [ "$$REDIS_PASSWORD" != "null" ]; then
exec redis-server --appendonly yes --maxmemory 256mb --maxmemory-policy allkeys-lru --requirepass "$$REDIS_PASSWORD"
else
exec redis-server --appendonly yes --maxmemory 256mb --maxmemory-policy allkeys-lru
fi
environment:
REDIS_PASSWORD: ${REDIS_PASSWORD:-}
expose:
- "6379"
volumes:
- redis_data:/data
networks:
faqhub:
aliases:
- faqhub-redis
healthcheck:
test:
[
"CMD-SHELL",
'if [ -n "$$REDIS_PASSWORD" ] && [ "$$REDIS_PASSWORD" != "null" ]; then redis-cli -a "$$REDIS_PASSWORD" ping; else redis-cli ping; fi | grep -q PONG',
]
interval: 10s
timeout: 3s
retries: 10
networks:
faqhub:
driver: bridge
dokploy-network:
external: true
name: ${DOKPLOY_NETWORK:-dokploy-network}
volumes:
mysql_data:
redis_data: