-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.prod.yml
More file actions
242 lines (233 loc) · 6.41 KB
/
docker-compose.prod.yml
File metadata and controls
242 lines (233 loc) · 6.41 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
239
240
241
242
# =====================================================
# Production Docker Compose for Webtool 4.2
# =====================================================
# This configuration is optimized for production deployment
# - No volume mounts for code (baked into image)
# - Proper restart policies
# - Health checks
# - Resource limits
# - Logging configuration
# =====================================================
services:
# ===================================================
# Caddy Web Server
# ===================================================
caddy:
image: caddy:latest
container_name: webtool-caddy
restart: unless-stopped
ports:
- "${APP_PORT:-80}:80"
volumes:
# Production Caddyfile
- ./docker/caddy/Caddyfile.production:/etc/caddy/Caddyfile:ro
# Share application public directory with app container
- app-public:/www/public:ro
networks:
- webtool
depends_on:
app:
condition: service_healthy
healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
labels:
- "com.webtool.service=caddy"
- "com.webtool.version=4.2"
# ===================================================
# Laravel Application (PHP-FPM)
# ===================================================
app:
build:
context: .
dockerfile: Dockerfile.production
args:
WWWUSER: ${WWWUSER:-1000}
WWWGROUP: ${WWWGROUP:-1000}
image: webtool:${APP_VERSION:-latest}
container_name: webtool-app
restart: unless-stopped
environment:
# Container environment
CONTAINER_ROLE: app
# Laravel will read from .env file
env_file:
- .env
extra_hosts:
# Allow container to access host machine services (MariaDB, Neo4J)
- "host.docker.internal:host-gateway"
volumes:
# Mount .env file
- ./.env:/www/.env:ro
# Persistent storage for uploaded files, logs, cache
- app-storage:/www/storage
- app-public:/www/public
networks:
- webtool
depends_on:
redis:
condition: service_healthy
healthcheck:
test: ["CMD-SHELL", "php -v > /dev/null 2>&1 && test -f /www/.env"]
interval: 30s
timeout: 10s
retries: 3
start_period: 60s
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "5"
labels:
- "com.webtool.service=app"
- "com.webtool.version=4.2"
# ===================================================
# Laravel Reverb (WebSockets)
# ===================================================
reverb:
build:
context: .
dockerfile: Dockerfile.production
args:
WWWUSER: ${WWWUSER:-1000}
WWWGROUP: ${WWWGROUP:-1000}
image: webtool:${APP_VERSION:-latest}
container_name: webtool-reverb
restart: unless-stopped
command: php artisan reverb:start --host=0.0.0.0 --port=8080
ports:
- "${REVERB_PORT:-8080}:8080"
environment:
CONTAINER_ROLE: reverb
env_file:
- .env
extra_hosts:
- "host.docker.internal:host-gateway"
volumes:
- ./.env:/www/.env:ro
- app-storage:/www/storage
networks:
- webtool
depends_on:
app:
condition: service_healthy
redis:
condition: service_healthy
healthcheck:
test: ["CMD-SHELL", "pgrep -f 'artisan reverb:start' || exit 1"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
labels:
- "com.webtool.service=reverb"
- "com.webtool.version=4.2"
# ===================================================
# Queue Worker
# ===================================================
queue:
build:
context: .
dockerfile: Dockerfile.production
args:
WWWUSER: ${WWWUSER:-1000}
WWWGROUP: ${WWWGROUP:-1000}
image: webtool:${APP_VERSION:-latest}
container_name: webtool-queue
restart: unless-stopped
command: php artisan queue:work --verbose --tries=3 --timeout=90 --sleep=3 --max-jobs=1000 --max-time=3600
environment:
CONTAINER_ROLE: queue
env_file:
- .env
extra_hosts:
- "host.docker.internal:host-gateway"
volumes:
- ./.env:/www/.env:ro
- app-storage:/www/storage
networks:
- webtool
depends_on:
app:
condition: service_healthy
redis:
condition: service_healthy
healthcheck:
test: ["CMD-SHELL", "pgrep -f 'artisan queue:work' || exit 1"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "5"
labels:
- "com.webtool.service=queue"
- "com.webtool.version=4.2"
# ===================================================
# Redis
# ===================================================
redis:
image: redis:7.2-alpine
container_name: webtool-redis
restart: unless-stopped
# ports:
# - "${FORWARD_REDIS_PORT:-6379}:6379"
# Note: Redis is only used internally by containers, no need to expose externally
command: redis-server --appendonly yes --maxmemory 256mb --maxmemory-policy allkeys-lru
volumes:
- redis-data:/data
networks:
- webtool
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 3s
retries: 3
start_period: 10s
logging:
driver: "json-file"
options:
max-size: "5m"
max-file: "3"
labels:
- "com.webtool.service=redis"
- "com.webtool.version=4.2"
# =====================================================
# Networks
# =====================================================
networks:
webtool:
driver: bridge
name: webtool-network
# =====================================================
# Volumes
# =====================================================
volumes:
# Laravel storage (uploads, logs, cache, sessions)
app-storage:
driver: local
name: webtool-storage
# Laravel public directory (shared with Caddy)
app-public:
driver: local
name: webtool-public
# Redis persistent data
redis-data:
driver: local
name: webtool-redis