Repository navigation
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
75 lines (70 loc) · 1.75 KB
/
Copy pathdocker-compose.yml
File metadata and controls
75 lines (70 loc) · 1.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
services:
# PostgreSQL Database
db:
image: postgres:15-alpine
container_name: campus-db
environment:
POSTGRES_USER: ${DB_USER:-postgres}
POSTGRES_PASSWORD: ${DB_PASSWORD:-postgres}
POSTGRES_DB: ${DB_NAME:-starter-server}
ports:
- "${DB_PORT:-5432}:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${DB_USER:-postgres}"]
interval: 10s
timeout: 5s
retries: 5
networks:
- campus-network
# Backend API
backend:
build:
context: ./backend
dockerfile: Dockerfile
container_name: campus-backend
environment:
NODE_ENV: production
PORT: 5001
DB_HOST: db
DB_PORT: 5432
DB_NAME: ${DB_NAME:-starter-server}
DB_USER: ${DB_USER:-postgres}
DB_PASSWORD: ${DB_PASSWORD:-postgres}
ports:
- "${BACKEND_PORT:-5001}:5001"
depends_on:
db:
condition: service_healthy
# Uncomment volumes for development (hot-reload)
# volumes:
# - ./backend:/app
# - /app/node_modules
networks:
- campus-network
restart: unless-stopped
healthcheck:
test: ["CMD", "node", "-e", "require('http').get('http://localhost:5001/api', (r) => {process.exit(r.statusCode === 404 || r.statusCode === 200 ? 0 : 1)})"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
# Frontend React App
frontend:
build:
context: ./frontend
dockerfile: Dockerfile
container_name: campus-frontend
ports:
- "${FRONTEND_PORT:-3000}:80"
depends_on:
- backend
networks:
- campus-network
restart: unless-stopped
volumes:
postgres_data:
networks:
campus-network:
driver: bridge