forked from Nova-reward/Nova-Rewards
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
242 lines (234 loc) · 7.1 KB
/
Copy pathdocker-compose.yml
File metadata and controls
242 lines (234 loc) · 7.1 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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
services:
postgres:
build:
context: ./postgres
dockerfile: Dockerfile
restart: unless-stopped
env_file:
- .env.example
environment:
POSTGRES_DB: ${POSTGRES_DB:-nova_rewards}
POSTGRES_USER: ${POSTGRES_USER:-nova}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-changeme}
volumes:
- postgres_data:/var/lib/postgresql/data
- ./database:/docker-entrypoint-initdb.d:ro
- ./backups/wal:/var/lib/postgresql/wal-archive
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-nova} -d ${POSTGRES_DB:-nova_rewards}"]
interval: 5s
timeout: 5s
retries: 10
ports:
- "5432:5432"
command:
- postgres
- -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
logging:
driver: ${LOG_DRIVER:-json-file}
options:
awslogs-group: ${CLOUDWATCH_LOG_GROUP_PREFIX:-/nova-rewards}/${NODE_ENV:-development}/postgres
awslogs-region: ${AWS_REGION:-us-east-1}
awslogs-stream: postgres
awslogs-create-group: "true"
tag: "postgres"
redis:
image: redis:7-alpine
restart: unless-stopped
command: >
redis-server
--appendonly yes
--appendfsync everysec
--save 900 1
--save 300 10
--save 60 10000
--maxmemory ${REDIS_MAXMEMORY:-256mb}
--maxmemory-policy allkeys-lru
ports:
- "6379:6379"
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 5
logging:
driver: ${LOG_DRIVER:-json-file}
options:
awslogs-group: ${CLOUDWATCH_LOG_GROUP_PREFIX:-/nova-rewards}/${NODE_ENV:-development}/redis
awslogs-region: ${AWS_REGION:-us-east-1}
awslogs-stream: redis
awslogs-create-group: "true"
tag: "redis"
stellar:
image: stellar/quickstart:testing
command: --local --enable-stellar-rpc
ports:
- "8000:8000"
healthcheck:
test: ["CMD-SHELL", "curl -sf http://localhost:8000/rpc -d '{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"getHealth\"}' -H 'Content-Type: application/json' | grep -q '\"status\":\"healthy\"'"]
interval: 10s
timeout: 5s
retries: 12
start_period: 30s
logging:
driver: ${LOG_DRIVER:-json-file}
options:
awslogs-group: ${CLOUDWATCH_LOG_GROUP_PREFIX:-/nova-rewards}/${NODE_ENV:-development}/stellar
awslogs-region: ${AWS_REGION:-us-east-1}
awslogs-stream: stellar
awslogs-create-group: "true"
tag: "stellar"
# Runs pending migrations once on every `docker compose up`
migrate:
image: node:20-alpine
working_dir: /app
command: sh -c "npm install --prefix /app/database 2>/dev/null; node database/migrate.js"
env_file:
- .env.example
environment:
DATABASE_URL: postgresql://${POSTGRES_USER:-nova}:${POSTGRES_PASSWORD:-changeme}@postgres:5432/${POSTGRES_DB:-nova_rewards}
NODE_ENV: ${NODE_ENV:-development}
volumes:
- .:/app
depends_on:
postgres:
condition: service_healthy
restart: "no"
# Scheduled PostgreSQL backups (runs every 6 hours via crond)
pg-backup:
image: postgres:16-alpine
restart: unless-stopped
env_file:
- .env.example
environment:
DATABASE_URL: postgresql://${POSTGRES_USER:-nova}:${POSTGRES_PASSWORD:-changeme}@postgres:5432/${POSTGRES_DB:-nova_rewards}
BACKUP_RETAIN_DAYS: ${BACKUP_RETAIN_DAYS:-7}
BACKUP_S3_BUCKET: ${BACKUP_S3_BUCKET:-}
AWS_REGION: ${AWS_REGION:-us-east-1}
AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID:-}
AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY:-}
volumes:
- ./scripts/pg-backup.sh:/usr/local/bin/pg-backup.sh:ro
- pg_backups:/backups
depends_on:
postgres:
condition: service_healthy
command: >
sh -c "
apk add --no-cache aws-cli &&
chmod +x /usr/local/bin/pg-backup.sh &&
echo '0 */6 * * * /usr/local/bin/pg-backup.sh >> /var/log/pg-backup.log 2>&1' | crontab - &&
/usr/local/bin/pg-backup.sh &&
crond -f -l 8
"
backend:
build:
context: ./backend
dockerfile: Dockerfile
restart: unless-stopped
env_file:
- .env.example
environment:
PORT: 3001
NODE_ENV: ${NODE_ENV:-development}
DATABASE_URL: postgresql://${POSTGRES_USER:-nova}:${POSTGRES_PASSWORD:-changeme}@postgres:5432/${POSTGRES_DB:-nova_rewards}
REDIS_URL: redis://redis:6379
REDIS_MODE: single
ALLOWED_ORIGIN: http://localhost:3000
HORIZON_URL: http://stellar:8000
STELLAR_RPC_URL: http://stellar:8000/rpc
ports:
- "3001:3001"
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
migrate:
condition: service_completed_successfully
volumes:
- ./backend:/app
- backend_node_modules:/app/node_modules
healthcheck:
test: ["CMD-SHELL", "wget -qO- http://localhost:3001/ready || exit 1"]
interval: 10s
timeout: 5s
retries: 5
start_period: 20s
logging:
driver: ${LOG_DRIVER:-json-file}
options:
awslogs-group: ${CLOUDWATCH_LOG_GROUP_PREFIX:-/nova-rewards}/${NODE_ENV:-development}/backend
awslogs-region: ${AWS_REGION:-us-east-1}
awslogs-stream: backend
awslogs-create-group: "true"
tag: "backend"
frontend:
build:
context: ./frontend
dockerfile: Dockerfile
restart: unless-stopped
env_file:
- .env.example
environment:
NODE_ENV: development
HOST: 0.0.0.0
NEXT_PUBLIC_API_URL: http://localhost:3001
NEXT_PUBLIC_HORIZON_URL: http://localhost:8000
NEXT_PUBLIC_STELLAR_NETWORK: local
ports:
- "3000:3000"
depends_on:
backend:
condition: service_started
volumes:
- ./frontend:/app
- frontend_node_modules:/app/node_modules
healthcheck:
test: ["CMD-SHELL", "wget -qO- http://localhost:3000/api/health || exit 1"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
logging:
driver: ${LOG_DRIVER:-json-file}
options:
awslogs-group: ${CLOUDWATCH_LOG_GROUP_PREFIX:-/nova-rewards}/${NODE_ENV:-development}/frontend
awslogs-region: ${AWS_REGION:-us-east-1}
awslogs-stream: frontend
awslogs-create-group: "true"
tag: "frontend"
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
logging:
driver: ${LOG_DRIVER:-json-file}
options:
awslogs-group: ${CLOUDWATCH_LOG_GROUP_PREFIX:-/nova-rewards}/${NODE_ENV:-development}/gateway
awslogs-region: ${AWS_REGION:-us-east-1}
awslogs-stream: gateway
awslogs-create-group: "true"
tag: "gateway"
volumes:
postgres_data:
redis_data:
pg_backups:
backend_node_modules:
frontend_node_modules: