-
Notifications
You must be signed in to change notification settings - Fork 194
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
108 lines (102 loc) · 3.3 KB
/
Copy pathdocker-compose.yml
File metadata and controls
108 lines (102 loc) · 3.3 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
# TeachLink Backend - Development Environment
#
# Start with: docker compose up -d
# Stop with: docker compose down
#
# This runs:
# postgres:5432 - Primary database
# redis:6379 - Caching, sessions, and job queues
# app:3000 - NestJS API server (optional, can run locally instead)
#
# To run just the dependencies (recommended for local dev):
# docker compose up -d postgres redis
# npm run start:dev
version: "3.8"
networks:
teachlink:
driver: bridge
volumes:
postgres-data:
redis-data:
services:
# ──────────────────────────────────────────────
# PostgreSQL 16 - Primary database
# ──────────────────────────────────────────────
postgres:
image: postgres:16-alpine
container_name: teachlink-postgres
restart: unless-stopped
ports:
- "${DATABASE_PORT:-5432}:5432"
environment:
POSTGRES_USER: ${DATABASE_USER:-postgres}
POSTGRES_PASSWORD: ${DATABASE_PASSWORD:-postgres}
POSTGRES_DB: ${DATABASE_NAME:-teachlink}
volumes:
- postgres-data:/var/lib/postgresql/data
networks:
- teachlink
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${DATABASE_USER:-postgres} -d ${DATABASE_NAME:-teachlink}"]
interval: 5s
timeout: 5s
retries: 10
start_period: 10s
# ──────────────────────────────────────────────
# Redis 7 - Caching, session store, and queues
# ──────────────────────────────────────────────
redis:
image: redis:7-alpine
container_name: teachlink-redis
restart: unless-stopped
ports:
- "${REDIS_PORT:-6379}:6379"
command:
- redis-server
- --appendonly yes
- --appendfsync everysec
- --maxmemory 256mb
- --maxmemory-policy allkeys-lru
volumes:
- redis-data:/data
networks:
- teachlink
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 5s
retries: 10
start_period: 5s
# ──────────────────────────────────────────────
# NestJS API Server (optional - for dockerized dev)
# ──────────────────────────────────────────────
app:
build:
context: .
dockerfile: Dockerfile
target: production
container_name: teachlink-app
restart: unless-stopped
ports:
- "${APP_PORT:-3000}:3000"
env_file:
- .env
environment:
DATABASE_HOST: postgres
DATABASE_PORT: 5432
REDIS_HOST: redis
REDIS_PORT: 6379
NODE_ENV: ${NODE_ENV:-development}
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
networks:
- teachlink
healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:3000/health"]
interval: 30s
timeout: 10s
retries: 5
start_period: 30s