Skip to content

Commit 56ef632

Browse files
author
Peter Nguyen
committed
feat: add docker-compose configuration for multi-service setup including PostgreSQL, backend, and frontend
1 parent a288053 commit 56ef632

1 file changed

Lines changed: 59 additions & 0 deletions

File tree

docker-compose.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
version: '3.8'
2+
3+
services:
4+
# db
5+
db:
6+
image: postgres:17
7+
restart: unless-stopped
8+
environment:
9+
POSTGRES_USER: ${POSTGRES_USER:-postgres}
10+
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-password}
11+
POSTGRES_DB: ${POSTGRES_DB:-chaos}
12+
volumes:
13+
- postgres-data:/var/lib/postgresql/data
14+
ports:
15+
- "${POSTGRES_PORT:-5432}:5432"
16+
healthcheck:
17+
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-postgres} -d ${POSTGRES_DB:-chaos}"]
18+
interval: 10s
19+
timeout: 5s
20+
retries: 5
21+
22+
# server
23+
backend:
24+
image: ghcr.io/devsoc-unsw/chaos-backend:latest
25+
restart: unless-stopped
26+
depends_on:
27+
db:
28+
condition: service_healthy
29+
env_file:
30+
- ./backend/.env
31+
environment:
32+
DATABASE_URL: postgres://postgres:password@db:5432/chaos
33+
ports:
34+
- "${BACKEND_PORT:-8080}:8080"
35+
healthcheck:
36+
test: ["CMD-SHELL", "nc -z localhost 8080 || exit 1"]
37+
interval: 30s
38+
timeout: 10s
39+
retries: 3
40+
start_period: 40s
41+
42+
# next.js-frontend
43+
frontend:
44+
image: ghcr.io/devsoc-unsw/chaos-frontend:latest
45+
restart: unless-stopped
46+
depends_on:
47+
backend:
48+
condition: service_healthy
49+
env_file:
50+
- ./frontend-nextjs/.env
51+
environment:
52+
NEXT_PUBLIC_API_BASE_URL: ${NEXT_PUBLIC_API_BASE_URL:-http://backend:8080}
53+
NODE_ENV: production
54+
ports:
55+
- "${FRONTEND_PORT:-3000}:3000"
56+
57+
volumes:
58+
postgres-data:
59+
driver: local

0 commit comments

Comments
 (0)