-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.example.yml
More file actions
314 lines (266 loc) · 7.45 KB
/
docker-compose.example.yml
File metadata and controls
314 lines (266 loc) · 7.45 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
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
########################################
# Docker Compose Examples
# Copy to docker-compose.yml and customize
########################################
version: '3.8'
services:
#==========================================
# Production Setup (High Performance)
# Universal image - konfiguriert via ENV
#==========================================
app-production:
image: ghcr.io/rene-roscher/php:8.3 # oder: latest, 8.2, 8.4
container_name: laravel-app
ports:
- "80:80"
- "443:443"
volumes:
# Application code
- ./:/var/www
# Persist SSL certificates
- certbot-data:/etc/letsencrypt
- certbot-webroot:/var/www/certbot
# Optional: Custom configs
# - ./configs/custom.ini:/usr/local/etc/php/conf.d/99-custom.ini
environment:
# Application
APP_ENV: production
APP_DEBUG: "false"
APP_URL: https://example.com
# Database (use secrets in production!)
DB_HOST: mysql
DB_DATABASE: laravel
DB_USERNAME: laravel
DB_PASSWORD: ${DB_PASSWORD:-secret}
# Socket Configuration (Unix Socket = best performance)
FPM_LISTEN: /run/php/php-fpm.sock
# Alternativ für TCP Socket:
# FPM_LISTEN: 127.0.0.1:9000
# PHP Core
PHP_MEMORY_LIMIT: 512M
PHP_MAX_EXECUTION_TIME: 60
PHP_UPLOAD_MAX_FILESIZE: 200M
PHP_POST_MAX_SIZE: 200M
# FPM - Static for max performance (8GB+ Server)
FPM_PM_TYPE: static
FPM_PM_MAX_CHILDREN: 200
# OPcache - Maximum performance
OPCACHE_ENABLE: "1"
OPCACHE_MEMORY_CONSUMPTION: 512
OPCACHE_MAX_ACCELERATED_FILES: 50000
OPCACHE_VALIDATE_TIMESTAMPS: "0" # Production: no file checks
OPCACHE_JIT: tracing
OPCACHE_JIT_BUFFER_SIZE: 200M
# Nginx
NGINX_WEBROOT: /var/www/public
NGINX_WORKER_CONNECTIONS: 4096
NGINX_CLIENT_MAX_BODY_SIZE: 200M
# SSL/Certbot
CERTBOT_ENABLED: "true"
CERTBOT_EMAIL: admin@example.com
CERTBOT_DOMAINS: example.com,www.example.com
CERTBOT_AUTO_RENEW: "true"
# Laravel
LARAVEL_OPTIMIZE_ON_BOOT: "true"
AUTORUN_LARAVEL_STORAGE_LINK: "true"
AUTORUN_LARAVEL_MIGRATION: "false" # Vorsicht in Production!
# Cron
CRON_ENABLED: "true"
LARAVEL_SCHEDULE_ENABLED: "true"
healthcheck:
test: ["CMD", "/usr/local/bin/healthcheck.sh"]
interval: 30s
timeout: 3s
retries: 3
start_period: 40s
depends_on:
mysql:
condition: service_healthy
redis:
condition: service_healthy
networks:
- app-network
restart: unless-stopped
# Resource limits (High Performance Server 8GB+)
deploy:
resources:
limits:
cpus: '4'
memory: 8G
reservations:
cpus: '2'
memory: 4G
#==========================================
# Development Setup
# Gleiche Universal Image - nur andere ENV
#==========================================
app-development:
image: ghcr.io/rene-roscher/php:8.3
container_name: laravel-dev
ports:
- "8000:80"
volumes:
- ./:/var/www
environment:
APP_ENV: local
APP_DEBUG: "true"
DB_HOST: mysql
DB_DATABASE: laravel
DB_USERNAME: root
DB_PASSWORD: secret
# Socket (Unix = default)
FPM_LISTEN: /run/php/php-fpm.sock
# Development-friendly settings
PHP_MEMORY_LIMIT: 256M
PHP_DISPLAY_ERRORS: "On"
# OPcache: Code-Änderungen automatisch erkennen
OPCACHE_VALIDATE_TIMESTAMPS: "1"
OPCACHE_REVALIDATE_FREQ: 2
# Laravel: keine Optimierung im Dev-Modus
LARAVEL_OPTIMIZE_ON_BOOT: "false"
NGINX_WEBROOT: /var/www/public
LOG_LEVEL: debug
networks:
- app-network
profiles: ["dev"]
#==========================================
# Small Server Setup (512MB - 1GB RAM)
# Gleiche Image - ressourcen-sparende ENV
#==========================================
app-small:
image: ghcr.io/rene-roscher/php:8.3
container_name: laravel-small
ports:
- "80:80"
volumes:
- ./:/var/www
environment:
APP_ENV: production
# Socket Configuration
FPM_LISTEN: /run/php/php-fpm.sock
# Minimal resource usage
PHP_MEMORY_LIMIT: 128M
# FPM Dynamic für kleine Server
FPM_PM_TYPE: dynamic
FPM_PM_MAX_CHILDREN: 8
FPM_PM_START_SERVERS: 2
FPM_PM_MIN_SPARE_SERVERS: 2
FPM_PM_MAX_SPARE_SERVERS: 4
# OPcache reduziert
OPCACHE_MEMORY_CONSUMPTION: 128
OPCACHE_MAX_ACCELERATED_FILES: 8000
OPCACHE_VALIDATE_TIMESTAMPS: "0"
NGINX_WEBROOT: /var/www/public
NGINX_WORKER_CONNECTIONS: 1024
networks:
- app-network
profiles: ["small"]
deploy:
resources:
limits:
memory: 1G
#==========================================
# MySQL Database
#==========================================
mysql:
image: mysql:8.0
container_name: laravel-mysql
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD:-secret}
MYSQL_DATABASE: ${DB_DATABASE:-laravel}
MYSQL_USER: ${DB_USERNAME:-laravel}
MYSQL_PASSWORD: ${DB_PASSWORD:-secret}
volumes:
- mysql-data:/var/lib/mysql
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
interval: 10s
timeout: 5s
retries: 5
networks:
- app-network
restart: unless-stopped
#==========================================
# Redis Cache
#==========================================
redis:
image: redis:7-alpine
container_name: laravel-redis
ports:
- "6379:6379"
volumes:
- redis-data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 3s
retries: 5
networks:
- app-network
restart: unless-stopped
#==========================================
# Optional: Queue Worker (Separate Container)
# Nutzt gleiche Image, nur anderer Command
#==========================================
queue:
image: ghcr.io/rene-roscher/php:8.3
container_name: laravel-queue
command: php artisan queue:work --tries=3 --timeout=90
volumes:
- ./:/var/www
environment:
APP_ENV: production
DB_HOST: mysql
DB_DATABASE: laravel
REDIS_HOST: redis
# Queue Worker braucht weniger Ressourcen
PHP_MEMORY_LIMIT: 256M
FPM_LISTEN: /run/php/php-fpm.sock
depends_on:
- mysql
- redis
networks:
- app-network
restart: unless-stopped
profiles: ["with-queue"]
#==========================================
# Optional: Laravel Horizon
#==========================================
horizon:
image: ghcr.io/rene-roscher/php:8.3
container_name: laravel-horizon
command: php artisan horizon
volumes:
- ./:/var/www
environment:
APP_ENV: production
DB_HOST: mysql
REDIS_HOST: redis
LARAVEL_HORIZON_ENABLED: "true"
depends_on:
- mysql
- redis
networks:
- app-network
restart: unless-stopped
profiles: ["with-horizon"]
#==========================================
# Networks
#==========================================
networks:
app-network:
driver: bridge
#==========================================
# Volumes
#==========================================
volumes:
mysql-data:
driver: local
redis-data:
driver: local
certbot-data:
driver: local
certbot-webroot:
driver: local