-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.staging.yml
More file actions
executable file
·242 lines (232 loc) · 5.83 KB
/
Copy pathdocker-compose.staging.yml
File metadata and controls
executable file
·242 lines (232 loc) · 5.83 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
# Staging environment (production-like for testing)
services:
app:
build:
context: .
dockerfile: Dockerfile
target: production
args:
BUILD_TARGET: ssr
restart: unless-stopped
environment:
- APP_ENV=staging
- APP_DEBUG=false
- APP_URL=https://staging.yourdomain.com
- DB_CONNECTION=pgsql
- DB_HOST=postgres
- DB_PORT=5432
- DB_DATABASE=baselaravel12react_staging
- DB_USERNAME=laravel
- DB_PASSWORD=${DB_PASSWORD}
- REDIS_HOST=redis
- REDIS_PASSWORD=${REDIS_PASSWORD}
- REDIS_PORT=6379
- CACHE_DRIVER=redis
- SESSION_DRIVER=redis
- QUEUE_CONNECTION=redis
- LOG_CHANNEL=stack
- LOG_LEVEL=warning
- MAIL_MAILER=smtp
- SESSION_SECURE_COOKIE=true
- FILESYSTEM_DISK=minio
- MINIO_ACCESS_KEY=${MINIO_ACCESS_KEY:-minioadmin}
- MINIO_SECRET_KEY=${MINIO_SECRET_KEY:-minioadmin}
- MINIO_DEFAULT_REGION=us-east-1
- MINIO_BUCKET=laravel-staging
- MINIO_ENDPOINT=http://minio:9000
- MINIO_USE_PATH_STYLE_ENDPOINT=true
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
minio:
condition: service_healthy
networks:
- laravel
- traefik
labels:
- "traefik.enable=true"
- "traefik.http.routers.app-staging.rule=Host(`staging.yourdomain.com`)"
- "traefik.http.routers.app-staging.tls=true"
- "traefik.http.routers.app-staging.tls.certresolver=letsencrypt"
- "traefik.http.services.app-staging.loadbalancer.server.port=80"
deploy:
resources:
limits:
memory: 1G
reservations:
memory: 512M
postgres:
image: postgres:16-alpine
restart: unless-stopped
environment:
POSTGRES_DB: baselaravel12react_staging
POSTGRES_USER: laravel
POSTGRES_PASSWORD: ${DB_PASSWORD}
volumes:
- postgres_staging_data:/var/lib/postgresql/data
- ./docker/postgres/staging-backup:/backup
healthcheck:
test: ["CMD-SHELL", "pg_isready -U laravel"]
interval: 30s
timeout: 10s
retries: 3
networks:
- laravel
deploy:
resources:
limits:
memory: 512M
reservations:
memory: 256M
redis:
image: redis:7-alpine
restart: unless-stopped
command: redis-server --requirepass ${REDIS_PASSWORD} --appendonly yes --maxmemory 256mb --maxmemory-policy allkeys-lru
volumes:
- redis_staging_data:/data
healthcheck:
test: ["CMD", "redis-cli", "-a", "${REDIS_PASSWORD}", "ping"]
interval: 30s
timeout: 10s
retries: 3
networks:
- laravel
deploy:
resources:
limits:
memory: 256M
reservations:
memory: 128M
ssr:
build:
context: .
dockerfile: Dockerfile
target: production
restart: unless-stopped
environment:
- NODE_ENV=production
- SSR_PORT=13714
networks:
- laravel
command: node bootstrap/ssr/ssr.mjs
deploy:
resources:
limits:
memory: 256M
reservations:
memory: 128M
worker:
build:
context: .
dockerfile: Dockerfile
target: production
restart: unless-stopped
environment:
- APP_ENV=staging
- APP_DEBUG=false
- DB_CONNECTION=pgsql
- DB_HOST=postgres
- DB_PORT=5432
- DB_DATABASE=baselaravel12react_staging
- DB_USERNAME=laravel
- DB_PASSWORD=${DB_PASSWORD}
- REDIS_HOST=redis
- REDIS_PASSWORD=${REDIS_PASSWORD}
- QUEUE_CONNECTION=redis
- LOG_LEVEL=warning
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
networks:
- laravel
command: php artisan queue:work --sleep=3 --tries=3 --max-time=3600
deploy:
replicas: 2
resources:
limits:
memory: 512M
reservations:
memory: 256M
scheduler:
build:
context: .
dockerfile: Dockerfile
target: production
restart: unless-stopped
environment:
- APP_ENV=staging
- APP_DEBUG=false
- DB_CONNECTION=pgsql
- DB_HOST=postgres
- DB_PORT=5432
- DB_DATABASE=baselaravel12react_staging
- DB_USERNAME=laravel
- DB_PASSWORD=${DB_PASSWORD}
depends_on:
postgres:
condition: service_healthy
networks:
- laravel
command: >
sh -c "while true; do
php artisan schedule:run
sleep 60
done"
deploy:
resources:
limits:
memory: 256M
reservations:
memory: 128M
backup:
image: postgres:16-alpine
restart: "no"
environment:
PGPASSWORD: ${DB_PASSWORD}
volumes:
- ./docker/postgres/staging-backup:/backup
- postgres_staging_data:/var/lib/postgresql/data:ro
networks:
- laravel
profiles:
- backup
command: >
sh -c "pg_dump -h postgres -U laravel -d baselaravel12react_staging > /backup/staging_backup_$(date +%Y%m%d_%H%M%S).sql"
minio:
image: minio/minio:latest
restart: unless-stopped
ports:
- "9000:9000"
- "9001:9001"
environment:
- MINIO_ROOT_USER=${MINIO_ACCESS_KEY:-minioadmin}
- MINIO_ROOT_PASSWORD=${MINIO_SECRET_KEY:-minioadmin}
volumes:
- minio_staging_data:/data
networks:
- laravel
command: server /data --console-address ":9001"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
interval: 30s
timeout: 20s
retries: 3
deploy:
resources:
limits:
memory: 512M
reservations:
memory: 256M
volumes:
postgres_staging_data:
redis_staging_data:
minio_staging_data:
networks:
laravel:
driver: bridge
traefik:
external: true