-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
200 lines (191 loc) · 5.75 KB
/
Copy pathdocker-compose.yml
File metadata and controls
200 lines (191 loc) · 5.75 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
name: hayon
services:
# ============================================================
# Nginx — reverse proxy + TLS termination
# ============================================================
nginx:
image: nginx:1.27-alpine
container_name: hayon_nginx
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- ./certbot/conf:/etc/letsencrypt:ro
- ./certbot/www:/var/www/certbot:ro
depends_on:
- frontend
- backend
restart: unless-stopped
networks:
- hayon_net
deploy:
resources:
limits:
memory: 64M
# ============================================================
# Certbot — SSL renewal daemon
# ============================================================
certbot:
image: certbot/certbot:latest
container_name: hayon_certbot
volumes:
- ./certbot/conf:/etc/letsencrypt
- ./certbot/www:/var/www/certbot
entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"
networks:
- hayon_net
# ============================================================
# Frontend — Next.js standalone
# ============================================================
frontend:
build:
context: .
dockerfile: frontend/Dockerfile
args:
NEXT_PUBLIC_API_URL: ${NEXT_PUBLIC_API_URL}
NEXT_PUBLIC_VAPID_KEY: ${NEXT_PUBLIC_VAPID_KEY}
NEXT_PUBLIC_FIREBASE_API_KEY: ${NEXT_PUBLIC_FIREBASE_API_KEY}
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN: ${NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN}
NEXT_PUBLIC_FIREBASE_PROJECT_ID: ${NEXT_PUBLIC_FIREBASE_PROJECT_ID}
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET: ${NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET}
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID: ${NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID}
NEXT_PUBLIC_FIREBASE_APP_ID: ${NEXT_PUBLIC_FIREBASE_APP_ID}
NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID: ${NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID}
NEXT_PUBLIC_POSTHOG_KEY: ${NEXT_PUBLIC_POSTHOG_KEY}
NEXT_PUBLIC_POSTHOG_HOST: ${NEXT_PUBLIC_POSTHOG_HOST}
container_name: hayon_frontend
expose:
- "3000"
environment:
- NODE_ENV=production
- PORT=3000
- HOSTNAME=0.0.0.0
restart: unless-stopped
networks:
- hayon_net
deploy:
resources:
limits:
memory: 256M
# ============================================================
# Backend — Express API
# ============================================================
backend:
build:
context: .
dockerfile: backend/Dockerfile
container_name: hayon_backend
expose:
- "5000"
env_file:
- backend/.env
environment:
- NODE_ENV=production
- RABBITMQ_URL=amqp://${RABBITMQ_USER:-hayon}:${RABBITMQ_PASS:-hayon_secret}@rabbitmq:5672
- REDIS_HOST=redis
- REDIS_PORT=6379
depends_on:
rabbitmq:
condition: service_healthy
redis:
condition: service_healthy
restart: unless-stopped
networks:
- hayon_net
deploy:
resources:
limits:
memory: 256M
# ============================================================
# Worker — RabbitMQ consumer (same image, different CMD)
# ============================================================
worker:
build:
context: .
dockerfile: backend/Dockerfile
container_name: hayon_worker
command: ["node", "dist/workers/index.js"]
env_file:
- backend/.env
environment:
- NODE_ENV=production
- RABBITMQ_URL=amqp://${RABBITMQ_USER:-hayon}:${RABBITMQ_PASS:-hayon_secret}@rabbitmq:5672
- REDIS_HOST=redis
- REDIS_PORT=6379
depends_on:
rabbitmq:
condition: service_healthy
redis:
condition: service_healthy
restart: unless-stopped
networks:
- hayon_net
deploy:
resources:
limits:
memory: 200M
# ============================================================
# Redis — cache
# ============================================================
redis:
image: redis:7-alpine
container_name: hayon_redis
expose:
- "6379"
volumes:
- redis_data:/data
# maxmemory 100mb: prevents Redis from eating all RAM on t2.micro
# allkeys-lru: evict least-recently-used keys when memory is full
command: redis-server --appendonly yes --maxmemory 100mb --maxmemory-policy allkeys-lru
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
restart: unless-stopped
networks:
- hayon_net
deploy:
resources:
limits:
memory: 128M
# ============================================================
# RabbitMQ — message broker (with delayed message plugin)
# ============================================================
rabbitmq:
build:
context: ./rabbitmq
dockerfile: Dockerfile
container_name: hayon_rabbitmq
expose:
- "5672"
ports:
# Management UI — only accessible locally via SSH tunnel
- "127.0.0.1:15672:15672"
volumes:
- rabbitmq_data:/var/lib/rabbitmq
environment:
RABBITMQ_DEFAULT_USER: ${RABBITMQ_USER:-hayon}
RABBITMQ_DEFAULT_PASS: ${RABBITMQ_PASS:-hayon_secret}
# Limit memory usage — important for t2.micro
RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS: "-rabbit vm_memory_high_watermark 0.4"
healthcheck:
test: ["CMD", "rabbitmq-diagnostics", "ping"]
interval: 15s
timeout: 10s
retries: 10
start_period: 30s
restart: unless-stopped
networks:
- hayon_net
deploy:
resources:
limits:
memory: 256M
volumes:
redis_data:
rabbitmq_data:
networks:
hayon_net:
driver: bridge