Repository navigation
Expand file tree
/
Copy pathdocker-compose.yaml
More file actions
319 lines (304 loc) · 9.36 KB
/
Copy pathdocker-compose.yaml
File metadata and controls
319 lines (304 loc) · 9.36 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
315
316
317
318
319
# Copyright (c) 2025 Affilibuster by Ronen Druker.
services:
postgres:
build:
context: .
dockerfile_inline: |
FROM postgres:18-alpine
RUN cat > /docker-entrypoint-initdb.d/init-db.sh <<'EOF'
set -e
# Check if database exists, create only if it doesn't
psql -v ON_ERROR_STOP=1 --username "$$POSTGRES_USER" --dbname "$$POSTGRES_DB" <<-EOSQL
SELECT 'CREATE DATABASE "$$POSTGRES_DB"'
WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = '$$POSTGRES_DB')\gexec
GRANT ALL PRIVILEGES ON DATABASE "$$POSTGRES_DB" TO "$$POSTGRES_USER";
EOSQL
# Add UUID extension to the database (IF NOT EXISTS already handles re-runs)
psql -v ON_ERROR_STOP=1 --username "$$POSTGRES_USER" --dbname "$$POSTGRES_DB" <<-EOSQL
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
EOSQL
echo "Database initialized successfully!"
EOF
RUN chmod +x /docker-entrypoint-initdb.d/init-db.sh
restart: 'no'
logging:
driver: json-file
options:
max-size: '10m'
max-file: '5'
env_file: # Load environment variables from .env file at build time
- .env
environment:
# Tell PostgreSQL to listen on custom port (defaults to 5432)
PGPORT: ${POSTGRES_PORT}
# Pass POSTGRES_DB to init script
POSTGRES_DB: ${POSTGRES_DB}
command: postgres -p ${POSTGRES_PORT}
ports:
- '${POSTGRES_PORT}:${POSTGRES_PORT}'
volumes:
- postgres_lib:/var/lib/postgresql
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ['CMD-SHELL', 'pg_isready -p ${POSTGRES_PORT} -U ${POSTGRES_USER} -d ${POSTGRES_DB}']
interval: 5s
timeout: 10s
retries: 50
redis:
image: redis:7-alpine
restart: 'no'
logging:
driver: json-file
options:
max-size: '10m'
max-file: '5'
env_file: # Load environment variables from .env file at build time
- .env
command: redis-server --port ${REDIS_PORT}
ports:
- '${REDIS_PORT}:${REDIS_PORT}'
volumes:
- redis_data:/data
healthcheck:
test: ['CMD', 'redis-cli', '-p', '${REDIS_PORT}', 'ping']
interval: 5s
timeout: 10s
retries: 50
strapi:
build:
context: ./cms
dockerfile: Dockerfile
args:
CMS_PORT: ${CMS_PORT}
CMS_HOST: ${CMS_HOST}
CMS_PROTOCOL: ${CMS_PROTOCOL}
APP_KEYS: ${APP_KEYS}
restart: 'no'
logging:
driver: json-file
options:
max-size: '10m'
max-file: '5'
depends_on:
postgres:
condition: service_healthy
env_file: # Load environment variables from .env file at build time
- .env
environment:
NODE_EXTRA_CA_CERTS: '' # keep empty to disable, TLS certificates are handled by the proxy
POSTGRES_HOST: ${INTERNAL_POSTGRES_HOST}
expose:
- '${CMS_PORT}'
volumes:
- ./cms:/app
- ./contracts:/contracts
- ./data:/data
- ./.copyright-header.txt:/.copyright-header.txt:ro
healthcheck:
# Uses /api/health endpoint which checks entrypoint script completion (including seed import)
# noinspection HttpUrlsUsage
test: ['CMD', 'curl', '-f', 'http://${CMS_HOST}:${CMS_PORT}/api/health']
interval: 5s
timeout: 10s
retries: 120 # 5s * 120 = 600s (~10 minutes) to allow enough time for Strapi to boot
strapi-proxy:
build:
context: ./cms
dockerfile_inline: |
# Nginx reverse proxy for Strapi CMS with SSL support
FROM nginx:1.27-alpine
# Install gettext for envsubst (environment variable substitution)
RUN apk add --no-cache gettext
# Copy Nginx configuration template
COPY nginx.conf.template /etc/nginx/nginx.conf.template
# Create directory for certificates
RUN mkdir -p /etc/nginx/certs
# Create startup script to substitute env vars and start nginx
RUN echo '#!/bin/sh' > /docker-entrypoint.sh && \
echo 'envsubst '"'"'$$CMS_PORT $$CMS_HOST'"'"' < /etc/nginx/nginx.conf.template > /etc/nginx/nginx.conf' >> /docker-entrypoint.sh && \
echo 'exec nginx -g "daemon off;"' >> /docker-entrypoint.sh && \
chmod +x /docker-entrypoint.sh
# Expose HTTPS port and HTTP redirect port (1338)
EXPOSE ${CMS_PORT} 1338
# Use custom entrypoint
ENTRYPOINT ["/docker-entrypoint.sh"]
restart: 'no'
logging:
driver: json-file
options:
max-size: '10m'
max-file: '5'
depends_on:
strapi:
condition: service_healthy
env_file:
- .env
ports:
- '${CMS_PORT}:${CMS_PORT}'
volumes:
- ./certs:/etc/nginx/certs:ro
- nginx_cache:/var/cache/nginx
- nginx_run:/var/run
healthcheck:
test: ['CMD', 'curl', '-fk', '${CMS_PROTOCOL}://${CMS_HOST}:${CMS_PORT}/api/health']
interval: 5s
timeout: 10s
retries: 50
backend:
build:
context: ./backend
dockerfile: Dockerfile
args:
BACKEND_PORT: ${BACKEND_PORT}
restart: 'no'
logging:
driver: json-file
options:
max-size: '10m'
max-file: '5'
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
strapi-proxy:
condition: service_healthy
env_file: # Load environment variables from .env file at build time
- .env
environment:
POSTGRES_HOST: ${INTERNAL_POSTGRES_HOST}
REDIS_HOST: ${INTERNAL_REDIS_HOST}
CMS_HOST: ${INTERNAL_CMS_HOST}
ports:
- '${BACKEND_PORT}:${BACKEND_PORT}'
volumes:
- ./backend:/app
- ./contracts:/contracts
- ./data:/data
- backend_venv:/app/.venv
- ./certs:/certs:ro
healthcheck:
test: ['CMD', 'curl', '-fk', '${BACKEND_PROTOCOL}://${BACKEND_HOST}:${BACKEND_PORT}/health']
interval: 5s
timeout: 10s
retries: 50
the-green-brother:
build:
context: ./the-green-brother
dockerfile: Dockerfile
args:
THE_GREEN_BROTHER_PORT: ${THE_GREEN_BROTHER_PORT}
restart: 'no'
logging:
driver: json-file
options:
max-size: '10m'
max-file: '5'
depends_on:
backend:
condition: service_healthy
env_file: # Load environment variables from .env file at build time
- .env
environment:
# Next.js respects PORT env var for custom listen port
PORT: ${THE_GREEN_BROTHER_PORT}
NEXT_SERVER_SIDE_API_URL: '${BACKEND_PROTOCOL}://${INTERNAL_BACKEND_HOST}:${BACKEND_PORT}/v1'
ports:
- '${THE_GREEN_BROTHER_PORT}:${THE_GREEN_BROTHER_PORT}'
volumes:
- ./the-green-brother:/app
- ./frontend:/frontend
- ./scripts:/scripts:ro
- tgb_node_modules:/app/node_modules
- ./contracts:/contracts
- ./data:/data
- ./certs:/certs:ro
- .env:/app/.env
healthcheck:
test:
['CMD', 'curl', '-fk', '${THE_GREEN_BROTHER_PROTOCOL}://${THE_GREEN_BROTHER_HOST}:${THE_GREEN_BROTHER_PORT}']
interval: 5s
timeout: 10s
retries: 50
gentle-hawk:
build:
context: ./gentle-hawk
dockerfile: Dockerfile
args:
GENTLE_HAWK_PORT: ${GENTLE_HAWK_PORT:-3001}
restart: 'no'
logging:
driver: json-file
options:
max-size: '10m'
max-file: '5'
depends_on:
backend:
condition: service_healthy
env_file:
- .env
environment:
PORT: ${GENTLE_HAWK_PORT:-3001}
NEXT_SERVER_SIDE_API_URL: '${BACKEND_PROTOCOL}://${INTERNAL_BACKEND_HOST}:${BACKEND_PORT}/v1'
ports:
- '${GENTLE_HAWK_PORT:-3001}:${GENTLE_HAWK_PORT:-3001}'
volumes:
- ./gentle-hawk:/app
- ./frontend:/frontend
- ./scripts:/scripts:ro
- gh_node_modules:/app/node_modules
- ./contracts:/contracts
- ./data:/data
- ./certs:/certs:ro
- .env:/app/.env
healthcheck:
test:
['CMD', 'curl', '-fk', '${GENTLE_HAWK_PROTOCOL:-https}://${GENTLE_HAWK_HOST:-0.0.0.0}:${GENTLE_HAWK_PORT:-3001}']
interval: 5s
timeout: 10s
retries: 50
test-runner:
build:
context: ./the-green-brother
dockerfile: Dockerfile.test-runner
restart: 'no'
logging:
driver: json-file
options:
max-size: '10m'
max-file: '5'
depends_on:
the-green-brother:
condition: service_healthy
env_file:
- .env
environment:
# Point to frontend via host.docker.internal (like accessing from host browser)
PLAYWRIGHT_BASE_URL: 'https://host.docker.internal:${THE_GREEN_BROTHER_PORT}'
# Disable dev server startup in tests
SKIP_WEBSERVER: '1'
ports:
- '${PLAYWRIGHT_REPORT_PORT}:${PLAYWRIGHT_REPORT_PORT}'
volumes:
- ./the-green-brother:/app
- ./contracts:/contracts
- ./data:/data
- ./certs:/certs:ro
# Enable host.docker.internal for accessing host network (where frontend is exposed)
extra_hosts:
- 'host.docker.internal:host-gateway'
# Recommended Playwright Docker settings
ipc: host # Prevents Chromium from running out of memory
init: true # Avoids zombie processes
# Override entrypoint to prevent running frontend dev server
entrypoint: []
command: ['tail', '-f', '/dev/null']
volumes:
postgres_lib:
postgres_data:
redis_data:
backend_venv:
nginx_cache:
nginx_run:
tgb_node_modules:
gh_node_modules: