-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
197 lines (188 loc) · 5.1 KB
/
Copy pathdocker-compose.yml
File metadata and controls
197 lines (188 loc) · 5.1 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
services:
postgres:
image: postgres:16-alpine
container_name: cookquest-postgres
restart: unless-stopped
environment:
POSTGRES_USER: ${POSTGRES_USER:-cookquest}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-cookquest}
POSTGRES_DB: ${POSTGRES_DB:-cookquest}
ports:
- '5432:5432'
volumes:
- pgdata:/var/lib/postgresql/data
networks:
- backend
healthcheck:
test: ['CMD-SHELL', 'pg_isready -U ${POSTGRES_USER:-cookquest}']
interval: 5s
timeout: 5s
retries: 5
deploy:
resources:
limits:
memory: 512M
cpus: '1.0'
reservations:
memory: 128M
redis:
image: redis:7-alpine
container_name: cookquest-redis
restart: unless-stopped
command: >
redis-server
--maxmemory 128mb
--maxmemory-policy allkeys-lru
--requirepass ${REDIS_PASSWORD:-cookquest_redis}
networks:
- backend
healthcheck:
test: ['CMD', 'redis-cli', '-a', '${REDIS_PASSWORD:-cookquest_redis}', 'ping']
interval: 5s
timeout: 3s
retries: 5
deploy:
resources:
limits:
memory: 192M
cpus: '0.5'
cookquest-web:
image: ${COOKQUEST_WEB_IMAGE:-ghcr.io/lollinng/cookquest-web:latest}
build:
context: .
dockerfile: Dockerfile
args:
NEXT_PUBLIC_API_URL: ${NEXT_PUBLIC_API_URL:-http://localhost:3003/api/v1}
container_name: cookquest-web
restart: unless-stopped
ports:
- '3000:3000'
environment:
- NODE_ENV=${NODE_ENV:-production}
- NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL:-http://localhost:3003/api/v1}
depends_on:
- cookquest-api
networks:
- frontend
deploy:
resources:
limits:
memory: 512M
cpus: '1.0'
reservations:
memory: 128M
cookquest-api:
image: ${COOKQUEST_API_IMAGE:-ghcr.io/lollinng/cookquest-api:latest}
build:
context: ./backend/node-services/api-server
dockerfile: Dockerfile
container_name: cookquest-api
restart: unless-stopped
ports:
- '3003:3003'
environment:
- NODE_ENV=${NODE_ENV:-production}
- PORT=3003
- DATABASE_URL=postgresql://${POSTGRES_USER:-cookquest}:${POSTGRES_PASSWORD:-cookquest}@postgres:5432/${POSTGRES_DB:-cookquest}
- REDIS_URL=redis://:${REDIS_PASSWORD:-cookquest_redis}@redis:6379
- JWT_SECRET=${JWT_SECRET:?JWT_SECRET must be set}
- FRONTEND_URL=${FRONTEND_URL:-http://localhost:3000}
- ALLOWED_ORIGINS=${ALLOWED_ORIGINS:-}
- EMAIL_USER=${EMAIL_USER:-}
- EMAIL_APP_PASSWORD=${EMAIL_APP_PASSWORD:-}
- APP_URL=${APP_URL:-http://localhost:3000}
- SHARED_DIR=/shared
volumes:
- ./backend/shared:/shared:ro
- api_uploads:/app/uploads
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
networks:
- frontend
- backend
deploy:
resources:
limits:
memory: 512M
cpus: '1.0'
reservations:
memory: 128M
# ── Production-only services (start with: docker compose --profile prod up) ──
nginx:
build:
context: ./nginx
dockerfile: Dockerfile
container_name: cookquest-nginx
restart: unless-stopped
profiles:
- prod
ports:
- '80:80'
- '443:443'
environment:
- DOMAIN=${DOMAIN:-localhost}
- NGINX_ENVSUBST_FILTER=DOMAIN
volumes:
- certbot_conf:/etc/letsencrypt:ro
- certbot_www:/var/www/certbot:ro
depends_on:
- cookquest-web
- cookquest-api
networks:
- frontend
deploy:
resources:
limits:
memory: 128M
cpus: '0.5'
certbot:
image: certbot/certbot:latest
container_name: cookquest-certbot
restart: unless-stopped
profiles:
- prod
volumes:
- certbot_conf:/etc/letsencrypt
- certbot_www:/var/www/certbot
# Renew certs every 12 hours (certbot skips if not due)
entrypoint: /bin/sh -c "trap exit TERM; while :; do certbot renew --webroot -w /var/www/certbot --quiet; sleep 43200 & wait $${!}; done"
backup:
image: postgres:16-alpine
container_name: cookquest-backup
restart: unless-stopped
profiles:
- prod
volumes:
- ./scripts/backup-db.sh:/backup.sh:ro
- ./backups:/backups
environment:
POSTGRES_USER: ${POSTGRES_USER:-cookquest}
POSTGRES_DB: ${POSTGRES_DB:-cookquest}
PGPASSWORD: ${POSTGRES_PASSWORD:-cookquest}
RETAIN_DAYS: ${BACKUP_RETAIN_DAYS:-7}
# Run backup immediately on start, then every 24 hours
entrypoint: /bin/sh -c "trap exit TERM; while :; do sh /backup.sh; sleep 86400 & wait $${!}; done"
depends_on:
postgres:
condition: service_healthy
networks:
- backend
deploy:
resources:
limits:
memory: 256M
cpus: '0.5'
networks:
frontend:
driver: bridge
backend:
driver: bridge
internal: true # No external access — only API can reach DB/Redis
volumes:
pgdata:
api_uploads:
certbot_conf:
certbot_www: