-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker-compose.prod.yml
More file actions
182 lines (172 loc) · 4.84 KB
/
Copy pathdocker-compose.prod.yml
File metadata and controls
182 lines (172 loc) · 4.84 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
# Production compose file — used on EC2
# Uses pre-built images from GHCR (GitHub Container Registry)
# Images are built in GitHub Actions CI/CD, not here.
#
# Usage: docker compose -f docker-compose.prod.yml up -d
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 — pre-built image from GHCR
# ============================================================
frontend:
image: ${IMAGE_BASE}-frontend:latest
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 — pre-built image from GHCR
# ============================================================
backend:
image: ${IMAGE_BASE}-backend:latest
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 — same backend image, different command
# ============================================================
worker:
image: ${IMAGE_BASE}-worker:latest
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
# ============================================================
redis:
image: redis:7-alpine
container_name: hayon_redis
expose:
- "6379"
volumes:
- redis_data:/data
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 — pre-built image from GHCR (has delayed plugin)
# ============================================================
rabbitmq:
image: ${IMAGE_BASE}-rabbitmq:latest
container_name: hayon_rabbitmq
expose:
- "5672"
ports:
- "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}
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