-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.prod.yml
More file actions
121 lines (114 loc) · 3.99 KB
/
Copy pathdocker-compose.prod.yml
File metadata and controls
121 lines (114 loc) · 3.99 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
# ─────────────────────────────────────────────────────────────────
# FitCircle Pro — Production Docker Compose
#
# Usage:
# docker compose -f docker-compose.prod.yml up -d
# docker compose -f docker-compose.prod.yml pull && docker compose -f docker-compose.prod.yml up -d
#
# Requires on VPS:
# - /opt/fitcircle/server/.env (real secrets, never commit)
# - Docker + Docker Compose installed
# ─────────────────────────────────────────────────────────────────
services:
# ── MongoDB ──────────────────────────────────────────────────
mongodb:
image: mongo:7
container_name: fitcircle-mongodb
restart: always
volumes:
- mongodb_data:/data/db
networks:
- fitcircle-net
healthcheck:
test: ["CMD", "mongosh", "--eval", "db.adminCommand('ping')"]
interval: 30s
timeout: 10s
retries: 5
start_period: 20s
# ── Backend (Gateway + All Microservices) ────────────────────
# Pulled from Docker Hub — never built on VPS
backend:
image: ${DOCKERHUB_USERNAME}/fitcircle-backend:latest
container_name: fitcircle-backend
restart: always
# No direct port exposure — traffic goes through Nginx only
expose:
- "5000"
env_file:
- ./server/.env
environment:
AUTH_SERVICE: http://localhost:5001
USER_SERVICE: http://localhost:5002
USER_SERVICE_URL: http://localhost:5002
FEED_SERVICE: http://localhost:5003
STORE_SERVICE: http://localhost:5004
WORKOUT_SERVICE: http://localhost:5005
DIET_SERVICE: http://localhost:5006
CHAT_SERVICE: http://localhost:5007
NODE_ENV: production
depends_on:
mongodb:
condition: service_healthy
networks:
- fitcircle-net
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:5000/health"]
interval: 30s
timeout: 10s
retries: 5
start_period: 40s
# ── Frontend (React + Nginx static) ──────────────────────────
# Pulled from Docker Hub — never built on VPS
frontend:
image: ${DOCKERHUB_USERNAME}/fitcircle-frontend:latest
container_name: fitcircle-frontend
restart: always
# No direct port exposure — traffic goes through Nginx reverse proxy
expose:
- "80"
depends_on:
backend:
condition: service_healthy
networks:
- fitcircle-net
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost/"]
interval: 30s
timeout: 5s
retries: 3
start_period: 10s
# ── Nginx Reverse Proxy ───────────────────────────────────────
# Single public entry point — routes / to frontend, /api/ to backend
nginx:
image: nginx:1.27-alpine
container_name: fitcircle-nginx
restart: always
ports:
- "80:80"
# Uncomment when you add SSL:
# - "443:443"
volumes:
- ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf:ro
# Uncomment for SSL certificates (e.g. via Certbot):
# - /etc/letsencrypt:/etc/letsencrypt:ro
depends_on:
frontend:
condition: service_healthy
backend:
condition: service_healthy
networks:
- fitcircle-net
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost/health"]
interval: 30s
timeout: 5s
retries: 3
start_period: 15s
# Deployments are handled by GitHub Actions (CI/CD-driven).
# Watchtower removed — CI/CD provides controlled rollout + rollback.
volumes:
mongodb_data:
driver: local
networks:
fitcircle-net:
driver: bridge