-
Notifications
You must be signed in to change notification settings - Fork 98
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
169 lines (160 loc) · 4.57 KB
/
docker-compose.yml
File metadata and controls
169 lines (160 loc) · 4.57 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
services:
db:
image: postgres:15-alpine
container_name: web3-student-lab-db
restart: always
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: web3-student-lab
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 5s
retries: 5
redis:
image: redis:7-alpine
container_name: web3-student-lab-redis
restart: always
ports:
- "6380:6379"
command: redis-server --appendonly yes --maxmemory 256mb --maxmemory-policy allkeys-lru
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
# Redis Sentinel 1 - Monitors primary Redis instance
redis-sentinel-1:
image: redis:7-alpine
container_name: web3-student-lab-sentinel-1
restart: always
ports:
- "26379:26379"
command: redis-sentinel /etc/sentinel.conf --port 26379
volumes:
- ./redis-sentinel.conf:/etc/sentinel.conf:ro
depends_on:
- redis
healthcheck:
test: ["CMD", "redis-cli", "-p", "26379", "ping"]
interval: 10s
timeout: 5s
retries: 5
# Redis Sentinel 2
redis-sentinel-2:
image: redis:7-alpine
container_name: web3-student-lab-sentinel-2
restart: always
ports:
- "26380:26379"
command: redis-sentinel /etc/sentinel.conf --port 26379
volumes:
- ./redis-sentinel.conf:/etc/sentinel.conf:ro
depends_on:
- redis
healthcheck:
test: ["CMD", "redis-cli", "-p", "26379", "ping"]
interval: 10s
timeout: 5s
retries: 5
# Redis Cluster Node 1
redis-cluster-1:
image: redis:7-alpine
container_name: web3-student-lab-redis-cluster-1
restart: always
ports:
- "6381:6381"
- "16381:16381"
command: redis-server --port 6381 --cluster-enabled yes --cluster-config-file nodes-1.conf --cluster-node-timeout 5000 --appendonly yes
volumes:
- redis_cluster_1_data:/data
healthcheck:
test: ["CMD", "redis-cli", "-p", "6381", "ping"]
interval: 10s
timeout: 5s
retries: 5
# Redis Cluster Node 2
redis-cluster-2:
image: redis:7-alpine
container_name: web3-student-lab-redis-cluster-2
restart: always
ports:
- "6382:6382"
- "16382:16382"
command: redis-server --port 6382 --cluster-enabled yes --cluster-config-file nodes-2.conf --cluster-node-timeout 5000 --appendonly yes
volumes:
- redis_cluster_2_data:/data
depends_on:
- redis-cluster-1
healthcheck:
test: ["CMD", "redis-cli", "-p", "6382", "ping"]
interval: 10s
timeout: 5s
retries: 5
# Redis Cluster Node 3
redis-cluster-3:
image: redis:7-alpine
container_name: web3-student-lab-redis-cluster-3
restart: always
ports:
- "6383:6383"
- "16383:16383"
command: redis-server --port 6383 --cluster-enabled yes --cluster-config-file nodes-3.conf --cluster-node-timeout 5000 --appendonly yes
volumes:
- redis_cluster_3_data:/data
depends_on:
- redis-cluster-1
healthcheck:
test: ["CMD", "redis-cli", "-p", "6383", "ping"]
interval: 10s
timeout: 5s
retries: 5
backend:
build:
context: ./backend
dockerfile: Dockerfile
container_name: web3-student-lab-backend
restart: always
ports:
- "8080:8080"
environment:
- DATABASE_URL=postgresql://postgres:postgres@db:5432/web3-student-lab?schema=public
- NODE_ENV=development
- JWT_SECRET=your-secret-key-change-in-production
# Redis Configuration - Choose one of: standalone, sentinel, cluster
- REDIS_MODE=standalone
# Standalone Redis
- REDIS_HOST=redis
- REDIS_PORT=6379
# Redis Sentinel (activate by setting REDIS_MODE=sentinel)
- REDIS_SENTINELS=redis-sentinel-1:26379,redis-sentinel-2:26380
- REDIS_SENTINEL_NAME=mymaster
# Redis Cluster (activate by setting REDIS_MODE=cluster)
- REDIS_CLUSTER_NODES=redis-cluster-1:6381,redis-cluster-2:6382,redis-cluster-3:6383
# Cache warming and block polling
- CACHE_WARMING_INTERVAL=300000
- BLOCK_POLL_INTERVAL=10000
- INSTANCE_ID=backend-1
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy
networks:
- web3-network
networks:
web3-network:
driver: bridge
volumes:
postgres_data:
redis_data:
redis_cluster_1_data:
redis_cluster_2_data:
redis_cluster_3_data: