-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.existing-db.yml
More file actions
86 lines (82 loc) · 2.57 KB
/
docker-compose.existing-db.yml
File metadata and controls
86 lines (82 loc) · 2.57 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
# Docker Compose - Use with your existing stewardchms-db container
#
# Your existing DB has: POSTGRES_USER=postgres, POSTGRES_PASSWORD=postgres, POSTGRES_DB=stewardchms
#
# USAGE:
# 1. First, create a shared network and connect your existing DB to it:
# docker network create stewardchms-network
# docker network connect stewardchms-network stewardchms-db
#
# 2. Run migrations (first time only):
# docker-compose -f docker-compose.existing-db.yml --profile migrate up migrate
#
# 3. Start the app:
# docker-compose -f docker-compose.existing-db.yml up -d --build
#
# 4. Access the app at http://localhost
# Login: admin@stewardchms.local / admin123
services:
# Backend API
backend:
build:
context: .
dockerfile: backend/Dockerfile
container_name: stewardchms-backend
restart: unless-stopped
environment:
NODE_ENV: production
PORT: 3001
DATABASE_URL: postgresql://postgres:postgres@stewardchms-db:5432/stewardchms
# IMPORTANT: Change this to a secure random value in production!
# Generate with: openssl rand -hex 32
JWT_SECRET: ${JWT_SECRET:-a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6}
JWT_EXPIRES_IN: ${JWT_EXPIRES_IN:-7d}
CORS_ORIGIN: ${CORS_ORIGIN:-http://localhost}
ports:
- "3001:3001"
networks:
- stewardchms-network
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3001/api/health"]
interval: 30s
timeout: 10s
start_period: 10s
retries: 3
# Frontend (Nginx + React SPA)
frontend:
build:
context: .
dockerfile: frontend/Dockerfile
container_name: stewardchms-frontend
restart: unless-stopped
depends_on:
backend:
condition: service_healthy
ports:
- "80:80"
networks:
- stewardchms-network
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:80/"]
interval: 30s
timeout: 10s
start_period: 5s
retries: 3
# Database migrations runner (run once with --profile migrate)
migrate:
build:
context: .
dockerfile: backend/Dockerfile.migrate
container_name: stewardchms-migrate
environment:
DATABASE_URL: postgresql://postgres:postgres@stewardchms-db:5432/stewardchms
ADMIN_EMAIL: ${ADMIN_EMAIL:-admin@stewardchms.local}
ADMIN_PASSWORD: ${ADMIN_PASSWORD:-admin123}
ADMIN_NAME: ${ADMIN_NAME:-System Administrator}
networks:
- stewardchms-network
profiles:
- migrate
networks:
stewardchms-network:
external: true