-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.prod.yml
More file actions
169 lines (163 loc) · 5.07 KB
/
docker-compose.prod.yml
File metadata and controls
169 lines (163 loc) · 5.07 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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# Glassbox Docker Compose - Production Configuration
# This file pulls pre-built images from GitHub Container Registry (ghcr.io)
#
# Usage:
# docker-compose -f docker-compose.prod.yml up -d # Start all services
# docker-compose -f docker-compose.prod.yml logs -f # View logs
# docker-compose -f docker-compose.prod.yml down # Stop all services
# docker-compose -f docker-compose.prod.yml pull # Pull latest images
#
# Prerequisites:
# 1. Log in to ghcr.io: echo $GHCR_TOKEN | docker login ghcr.io -u USERNAME --password-stdin
# 2. Create .env file with required environment variables
# 3. Configure nginx.conf with your domain
# 4. Set up SSL certificates in ./certs directory
services:
# ==========================================================================
# Nginx Reverse Proxy
# ==========================================================================
nginx:
image: nginx:alpine
container_name: glassbox-nginx
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
- ./certs:/etc/nginx/certs:ro
- ./certbot/www:/var/www/certbot:ro
depends_on:
frontend:
condition: service_healthy
backend:
condition: service_healthy
restart: unless-stopped
networks:
- glassbox-network
healthcheck:
test: ["CMD", "nginx", "-t"]
interval: 30s
timeout: 10s
retries: 3
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
# ==========================================================================
# Next.js Frontend (From GitHub Container Registry)
# ==========================================================================
frontend:
image: ${FRONTEND_IMAGE:-ghcr.io/your-org/glassbox/frontend}:${VERSION:-latest}
container_name: glassbox-frontend
environment:
- NODE_ENV=production
- NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}
- NEXTAUTH_URL=${NEXTAUTH_URL}
- NEXTAUTH_SECRET=${NEXTAUTH_SECRET}
- GOOGLE_CLIENT_ID=${GOOGLE_CLIENT_ID}
- GOOGLE_CLIENT_SECRET=${GOOGLE_CLIENT_SECRET}
depends_on:
backend:
condition: service_healthy
restart: unless-stopped
networks:
- glassbox-network
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3000/"]
interval: 30s
timeout: 10s
start_period: 30s
retries: 3
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
deploy:
resources:
limits:
memory: 1G
reservations:
memory: 512M
# ==========================================================================
# Nest.js Backend (From GitHub Container Registry)
# ==========================================================================
backend:
image: ${BACKEND_IMAGE:-ghcr.io/your-org/glassbox/backend}:${VERSION:-latest}
container_name: glassbox-backend
environment:
- NODE_ENV=production
- PORT=4000
- DATABASE_URL=postgresql://glassbox:${DB_PASSWORD}@postgres:5432/glassbox
- JWT_SECRET=${JWT_SECRET}
- NEXTAUTH_SECRET=${NEXTAUTH_SECRET}
- FRONTEND_URL=${FRONTEND_URL}
depends_on:
postgres:
condition: service_healthy
restart: unless-stopped
networks:
- glassbox-network
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:4000/"]
interval: 30s
timeout: 10s
start_period: 30s
retries: 3
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
deploy:
resources:
limits:
memory: 2G
reservations:
memory: 1G
# ==========================================================================
# PostgreSQL Database
# ==========================================================================
postgres:
image: postgres:16-alpine
container_name: glassbox-postgres
environment:
- POSTGRES_USER=glassbox
- POSTGRES_PASSWORD=${DB_PASSWORD}
- POSTGRES_DB=glassbox
volumes:
- postgres_data:/var/lib/postgresql/data
- ./backups:/backups
restart: unless-stopped
networks:
- glassbox-network
healthcheck:
test: ["CMD-SHELL", "pg_isready -U glassbox -d glassbox"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
deploy:
resources:
limits:
memory: 512M
reservations:
memory: 256M
# ==========================================================================
# Networks
# ==========================================================================
networks:
glassbox-network:
driver: bridge
# ==========================================================================
# Volumes
# ==========================================================================
volumes:
postgres_data:
driver: local