forked from Nova-reward/Nova-Rewards
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.staging.yml
More file actions
158 lines (151 loc) · 3.8 KB
/
Copy pathdocker-compose.staging.yml
File metadata and controls
158 lines (151 loc) · 3.8 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
# docker-compose.staging.yml — Staging environment
# Usage: docker compose -f docker-compose.staging.yml up --build
# Requires: novaRewards/.env.staging
services:
postgres:
build:
context: ./postgres
dockerfile: Dockerfile
restart: unless-stopped
env_file: .env.staging
environment:
POSTGRES_DB: ${POSTGRES_DB:-nova_rewards_staging}
POSTGRES_USER: ${POSTGRES_USER:-nova_staging}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?POSTGRES_PASSWORD is required}
volumes:
- postgres_data:/var/lib/postgresql/data
- ./database:/docker-entrypoint-initdb.d:ro
command:
- postgres
- -c
- max_connections=50
- -c
- shared_buffers=256MB
- -c
- wal_level=replica
- -c
- archive_mode=on
- -c
- archive_timeout=60s
- -c
- max_wal_senders=3
- -c
- archive_command=/usr/local/bin/archive-wal.sh %p %f
- -c
- log_statement=ddl
- -c
- log_min_duration_statement=500
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-nova_staging} -d ${POSTGRES_DB:-nova_rewards_staging}"]
interval: 10s
timeout: 5s
retries: 10
deploy:
resources:
limits:
cpus: "0.5"
memory: 512M
migrate:
build:
context: ./backend
dockerfile: Dockerfile
command: ["node", "/migrations/migrate.js"]
env_file: .env.staging
environment:
DATABASE_URL: postgresql://${POSTGRES_USER:-nova_staging}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:-nova_rewards_staging}
NODE_ENV: staging
volumes:
- ./database:/migrations:ro
depends_on:
postgres:
condition: service_healthy
restart: on-failure
redis:
image: redis:7-alpine
restart: unless-stopped
command: >
redis-server
--appendonly yes
--appendfsync everysec
--save 900 1
--save 300 10
--maxmemory 128mb
--maxmemory-policy allkeys-lru
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 3s
retries: 5
deploy:
resources:
limits:
cpus: "0.25"
memory: 192M
backend:
build:
context: ./backend
dockerfile: Dockerfile
restart: unless-stopped
env_file: .env.staging
environment:
PORT: 3001
NODE_ENV: staging
DATABASE_URL: postgresql://${POSTGRES_USER:-nova_staging}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:-nova_rewards_staging}
REDIS_URL: redis://redis:6379
REDIS_MODE: single
ALLOWED_ORIGIN: ${ALLOWED_ORIGIN:?ALLOWED_ORIGIN is required}
# Connection pool — conservative for staging
DB_POOL_MIN: 2
DB_POOL_MAX: 10
ports:
- "3001:3001"
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
migrate:
condition: service_completed_successfully
deploy:
resources:
limits:
cpus: "0.5"
memory: 512M
frontend:
build:
context: ./frontend
dockerfile: Dockerfile
restart: unless-stopped
env_file: .env.staging
environment:
NODE_ENV: staging
NEXT_PUBLIC_API_URL: ${NEXT_PUBLIC_API_URL:?NEXT_PUBLIC_API_URL is required}
ports:
- "3000:3000"
depends_on:
backend:
condition: service_started
deploy:
resources:
limits:
cpus: "0.5"
memory: 512M
gateway:
image: nginx:1.25-alpine
restart: unless-stopped
ports:
- "8080:80"
volumes:
- ../deployment/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
depends_on:
- backend
deploy:
resources:
limits:
cpus: "0.25"
memory: 64M
volumes:
postgres_data:
redis_data: