-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
132 lines (125 loc) · 3.26 KB
/
docker-compose.yml
File metadata and controls
132 lines (125 loc) · 3.26 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
version: "3.8"
services:
# PostgreSQL Database
postgres:
image: postgres:15-alpine
container_name: leetlab-postgres
restart: unless-stopped
environment:
POSTGRES_DB: postgres
POSTGRES_USER: myuser
POSTGRES_PASSWORD: mypassword
PGDATA: /var/lib/postgresql/data/pgdata
volumes:
- postgres_data:/var/lib/postgresql/data
- ./init-db.sql:/docker-entrypoint-initdb.d/init-db.sql
ports:
- "5432:5432"
networks:
- leetlab-network
healthcheck:
test: ["CMD-SHELL", "pg_isready -U myuser -d postgres"]
interval: 10s
timeout: 5s
retries: 5
# Redis Cache (for session storage and caching)
redis:
image: redis:7-alpine
container_name: leetlab-redis
restart: unless-stopped
command: redis-server --appendonly yes --requirepass redispassword
volumes:
- redis_data:/data
ports:
- "6379:6379"
networks:
- leetlab-network
healthcheck:
test: ["CMD", "redis-cli", "--raw", "incr", "ping"]
interval: 10s
timeout: 3s
retries: 5
# Backend Service
backend:
build:
context: ./backend
dockerfile: Dockerfile
container_name: leetlab-backend
restart: unless-stopped
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
environment:
NODE_ENV: production
PORT: 8080
DATABASE_URL: postgresql://myuser:mypassword@postgres:5432/postgres
REDIS_URL: redis://:redispassword@redis:6379
SECRET: ${JWT_SECRET:-your-super-secret-jwt-key-change-this-in-production}
REFRESH_SECRET: ${REFRESH_SECRET:-your-super-secret-refresh-key-change-this-in-production}
JUDGE0_API_URL: ${JUDGE0_API_URL:-https://judge0-ce.p.sulu.sh}
SULU_API_KEY: ${SULU_API_KEY}
RAZORPAY_KEY_ID: ${RAZORPAY_KEY_ID}
RAZORPAY_KEY_SECRET: ${RAZORPAY_KEY_SECRET}
SMTP_HOST: ${SMTP_HOST}
SMTP_PORT: ${SMTP_PORT}
SMTP_USER: ${SMTP_USER}
SMTP_PASS: ${SMTP_PASS}
volumes:
- ./backend/uploads:/app/uploads
ports:
- "8080:8080"
networks:
- leetlab-network
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/api/v1/auth/check"]
interval: 30s
timeout: 10s
retries: 3
# Frontend Service
frontend:
build:
context: ./frontend
dockerfile: Dockerfile
container_name: leetlab-frontend
restart: unless-stopped
depends_on:
- backend
ports:
- "3000:80"
networks:
- leetlab-network
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost/health"]
interval: 30s
timeout: 10s
retries: 3
# Nginx Reverse Proxy
nginx:
image: nginx:alpine
container_name: leetlab-nginx
restart: unless-stopped
depends_on:
- frontend
- backend
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- ./nginx/ssl:/etc/nginx/ssl:ro
- ./nginx/logs:/var/log/nginx
networks:
- leetlab-network
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost/health"]
interval: 30s
timeout: 10s
retries: 3
volumes:
postgres_data:
redis_data:
networks:
leetlab-network:
driver: bridge