-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.prod-local.yml
More file actions
212 lines (202 loc) · 6.78 KB
/
Copy pathdocker-compose.prod-local.yml
File metadata and controls
212 lines (202 loc) · 6.78 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
version: '3.8'
services:
mongodb:
image: mongo:7.0
container_name: litecoin-mongodb-prod-local
environment:
# Only set init DB variables if MONGO_ROOT_PASSWORD is set
# MongoDB requires both USERNAME and PASSWORD to be set together
- MONGO_INITDB_ROOT_USERNAME=${MONGO_ROOT_USERNAME:-admin}
- MONGO_INITDB_ROOT_PASSWORD=${MONGO_ROOT_PASSWORD:-}
# Only enable --auth if MONGO_ROOT_PASSWORD is set
# --bind_ip_all allows connections from other containers
# Use entrypoint override to conditionally set/unset init DB vars
entrypoint: >
sh -c "
if [ -n \"$$MONGO_ROOT_PASSWORD\" ]; then
export MONGO_INITDB_ROOT_USERNAME=\"$${MONGO_ROOT_USERNAME:-admin}\";
export MONGO_INITDB_ROOT_PASSWORD=\"$$MONGO_ROOT_PASSWORD\";
else
unset MONGO_INITDB_ROOT_USERNAME;
unset MONGO_INITDB_ROOT_PASSWORD;
fi;
exec docker-entrypoint.sh mongod --bind_ip_all $${MONGO_ROOT_PASSWORD:+--auth}
"
ports:
- "27017:27017"
volumes:
- mongodb_dev_data:/data/db
# - mongodb_data:/data/db
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "if [ -n \"$$MONGO_ROOT_PASSWORD\" ]; then mongosh --quiet --username $$MONGO_ROOT_USERNAME --password $$MONGO_ROOT_PASSWORD --authenticationDatabase admin --eval \"db.adminCommand('ping')\"; else mongosh --quiet --eval \"db.adminCommand('ping')\"; fi"]
interval: 30s
timeout: 10s
retries: 5
start_period: 30s
backend:
build:
context: ./backend
dockerfile: Dockerfile
container_name: litecoin-backend-prod-local
ports:
- "8000:8000"
env_file:
- ./.env.prod-local
- ./backend/.env
environment:
# Production-local-specific overrides
# Note: GOOGLE_API_KEY is loaded from ./backend/.env via env_file above
- NODE_ENV=production
# Set MONGO_URI if not provided in .env.prod-local (uses Docker service name)
- MONGO_URI=${MONGO_URI:-mongodb://mongodb:27017}
depends_on:
mongodb:
condition: service_healthy
volumes:
- ./backend/monitoring/data:/app/backend/monitoring/data
restart: unless-stopped
networks:
default:
aliases:
- litecoin-backend
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
payload_cms:
build:
context: ./payload_cms
dockerfile: Dockerfile
container_name: litecoin-payload-cms-prod-local
ports:
- "3001:3000"
env_file:
- ./.env.prod-local
- ./payload_cms/.env
environment:
# Production-local-specific overrides
# Note: PAYLOAD_SECRET is loaded from ./payload_cms/.env via env_file above
- NODE_ENV=production
# Set DATABASE_URI if not provided in .env.prod-local (uses Docker service name)
- DATABASE_URI=${DATABASE_URI:-mongodb://mongodb:27017/payload_cms}
depends_on:
backend:
condition: service_healthy
mongodb:
condition: service_healthy
restart: unless-stopped
networks:
default:
aliases:
- litecoin-payload-cms
healthcheck:
test: ["CMD", "node", "-e", "require('http').get('http://localhost:3000', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
frontend:
build:
context: ./frontend
dockerfile: Dockerfile
args:
- NEXT_PUBLIC_BACKEND_URL=${NEXT_PUBLIC_BACKEND_URL:-http://localhost:8000}
- NEXT_PUBLIC_PAYLOAD_URL=${NEXT_PUBLIC_PAYLOAD_URL:-http://localhost:3001}
container_name: litecoin-frontend-prod-local
ports:
- "3000:3000"
env_file:
- ./.env.prod-local
environment:
# Production-local-specific overrides
- NODE_ENV=production
depends_on:
backend:
condition: service_healthy
restart: unless-stopped
networks:
default:
aliases:
- litecoin-frontend
healthcheck:
test: ["CMD", "node", "-e", "const rawHost = process.env.HOST || process.env.HOSTNAME || '127.0.0.1'; const host = ['0.0.0.0', '::', '::0', '::ffff:0:0'].includes(rawHost) ? '127.0.0.1' : rawHost; require('http').get(`http://$${host}:3000/chat`, (r) => {process.exit(r.statusCode >= 200 && r.statusCode < 400 ? 0 : 1)}).on('error', () => process.exit(1))"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
prometheus:
image: prom/prometheus:latest
container_name: litecoin-prometheus-prod-local
ports:
- "9090:9090"
volumes:
- ./monitoring/prometheus.yml:/etc/prometheus/prometheus.yml:ro
- ./monitoring/alerts.yml:/etc/prometheus/alerts.yml:ro
- prometheus_data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/usr/share/prometheus/console_libraries'
- '--web.console.templates=/usr/share/prometheus/consoles'
- '--storage.tsdb.retention.time=30d'
- '--web.enable-lifecycle'
restart: unless-stopped
depends_on:
backend:
condition: service_healthy
grafana:
image: grafana/grafana:latest
container_name: litecoin-grafana-prod-local
ports:
- "3002:3000"
env_file:
- ./.env.prod-local
environment:
- GF_SECURITY_ADMIN_USER=${GRAFANA_ADMIN_USER:-admin}
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_ADMIN_PASSWORD:?GRAFANA_ADMIN_PASSWORD must be set}
- GF_USERS_ALLOW_SIGN_UP=false
volumes:
- grafana_data:/var/lib/grafana
- ./monitoring/grafana/provisioning:/etc/grafana/provisioning
- ./monitoring/grafana/dashboards:/var/lib/grafana/dashboards
restart: unless-stopped
depends_on:
prometheus:
condition: service_started
cloudflared:
image: cloudflare/cloudflared:latest
container_name: litecoin-cloudflared-prod-local
command: tunnel --no-autoupdate run --token ${CLOUDFLARE_TUNNEL_TOKEN}
env_file:
- ./.env.prod-local
environment:
- TUNNEL_TOKEN=${CLOUDFLARE_TUNNEL_TOKEN}
depends_on:
backend:
condition: service_healthy
payload_cms:
condition: service_healthy
frontend:
condition: service_healthy
restart: unless-stopped
redis:
image: redis:7-alpine
container_name: litecoin-redis-prod-local
# Only add --requirepass if REDIS_PASSWORD is set
command: >
sh -c "if [ -n \"$$REDIS_PASSWORD\" ]; then
redis-server --requirepass $$REDIS_PASSWORD --save 60 1 --loglevel warning;
else
redis-server --save 60 1 --loglevel warning;
fi"
volumes:
- redis_data:/data
restart: unless-stopped
volumes:
prometheus_data:
grafana_data:
mongodb_dev_data:
redis_data: