-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
153 lines (147 loc) · 3.86 KB
/
Copy pathdocker-compose.yml
File metadata and controls
153 lines (147 loc) · 3.86 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
services:
# Nginx Reverse Proxy with SSL, Rate Limiting, Caching, WebSocket
nginx:
image: nginx:alpine
container_name: tnp-nginx
ports:
- "80:80"
- "443:443"
- "8080:8080"
volumes:
- ./nginx-reverse-proxy.conf:/etc/nginx/nginx.conf:ro
# SSL Certificates (create certs/ folder with self-signed or real certificates)
- ./certs:/etc/nginx/certs:ro
# Cache directories for uploads and API responses
- nginx_cache_resume:/var/cache/nginx/resume
- nginx_cache_api:/var/cache/nginx/api
# ACME challenges for Let's Encrypt
- ./certbot:/var/www/certbot:ro
# Nginx logs
- nginx_logs:/var/log/nginx
depends_on:
- backend
- frontend
networks:
- tnp-network
restart: unless-stopped
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:80/health"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
logging:
driver: "json-file"
options:
max-size: "50m"
max-file: "5"
environment:
# For monitoring
TZ: UTC
# PostgreSQL Database
postgres:
image: postgres:15-alpine
container_name: tnp-postgres
environment:
POSTGRES_USER: ${DB_USER:-neondb_owner}
POSTGRES_PASSWORD: ${DB_PASSWORD:-postgres}
POSTGRES_DB: ${DB_NAME:-neondb}
ports:
- "${DB_PORT:-5432}:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
networks:
- tnp-network
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${DB_USER:-neondb_owner} || exit 1"]
interval: 5s
timeout: 10s
retries: 10
start_period: 20s
restart: unless-stopped
# Redis Cache
redis:
image: redis:7-alpine
container_name: tnp-redis
ports:
- "${REDIS_PORT:-6379}:6379"
volumes:
- redis_data:/data
networks:
- tnp-network
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 10s
retries: 10
start_period: 20s
restart: unless-stopped
command: redis-server --appendonly yes
# Backend API
backend:
build:
context: ./backend
dockerfile: Dockerfile
container_name: tnp-backend
environment:
NODE_ENV: ${NODE_ENV:-production}
PORT: 3001
DATABASE_URL: postgresql://${DB_USER:-neondb_owner}:${DB_PASSWORD:-postgres}@postgres:5432/${DB_NAME:-neondb}
REDIS_URL: redis://redis:6379
REDIS_HOST: redis
REDIS_PORT: 6379
JWT_SECRET: ${JWT_SECRET:-dev-secret-key-change-in-production}
JWT_REFRESH_SECRET: ${JWT_REFRESH_SECRET:-dev-refresh-secret-key}
SKIP_DATABASE_INIT: "false"
SKIP_REDIS_INIT: "false"
CORS_ORIGIN: ${CORS_ORIGIN:-http://localhost}
ports:
- "${BACKEND_PORT:-3001}:3001"
depends_on:
- postgres
- redis
networks:
- tnp-network
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3001/health"]
interval: 10s
timeout: 5s
retries: 5
start_period: 60s
# Frontend App
frontend:
build:
context: ./frontend
dockerfile: Dockerfile
container_name: tnp-frontend
environment:
VITE_API_BASE_URL: ${VITE_API_BASE_URL:-http://localhost}
# Nginx reverse proxy handles external ports
# ports:
# - "${FRONTEND_PORT:-80}:80"
depends_on:
- backend
networks:
- tnp-network
restart: unless-stopped
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:80/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
volumes:
postgres_data:
driver: local
redis_data:
driver: local
nginx_cache_resume:
driver: local
nginx_cache_api:
driver: local
nginx_logs:
driver: local
networks:
tnp-network:
driver: bridge