-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathdocker-compose.cluster.yml
More file actions
57 lines (55 loc) · 2.11 KB
/
docker-compose.cluster.yml
File metadata and controls
57 lines (55 loc) · 2.11 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
# Local single-node Redis Cluster for testing cluster-mode code paths.
# NOT for production. AWS MemoryDB is the production target.
#
# Why single-node: a 1-shard Redis Cluster speaks the same cluster protocol
# (CLUSTER SLOTS, slot routing, MOVED redirects on topology change) as a
# multi-shard cluster, so the application's cluster-mode code path is fully
# exercised. A multi-node local cluster on Docker Desktop for Mac runs into
# `cluster-announce-ip` cross-namespace issues with no clean fix that
# survives between Linux and Mac. Production matches: single-shard MemoryDB.
#
# Usage:
# docker compose -f docker-compose.cluster.yml up -d
# docker compose -f docker-compose.cluster.yml down -v
#
# Default port: 7100 (avoids macOS AirPlay on 7000). Override:
# REDIS_CLUSTER_PORT=7200 docker compose -f docker-compose.cluster.yml up -d
# REDIS_CLUSTER_TEST_URL=redis://127.0.0.1:7200 \
# cargo test -p solver-storage --features cluster-tests \
# --test redis_cluster_integration
services:
redis-1:
image: redis:7-alpine
container_name: oif-redis-cluster-1
ports:
- "${REDIS_CLUSTER_PORT:-7100}:${REDIS_CLUSTER_PORT:-7100}"
command: >
redis-server
--port ${REDIS_CLUSTER_PORT:-7100}
--cluster-enabled yes
--cluster-config-file /data/nodes.conf
--cluster-node-timeout 5000
--appendonly yes
cluster-init:
image: redis:7-alpine
depends_on: [redis-1]
network_mode: host
environment:
REDIS_CLUSTER_PORT: "${REDIS_CLUSTER_PORT:-7100}"
entrypoint:
- sh
- -ec
- |
until redis-cli -p $$REDIS_CLUSTER_PORT ping | grep -q PONG; do
sleep 1
done
assigned="$$(redis-cli -p $$REDIS_CLUSTER_PORT cluster info \
| awk -F: '/cluster_slots_assigned/{print $$2}' \
| tr -d '\r')"
if [ -z "$$assigned" ] || [ "$$assigned" = "0" ]; then
redis-cli -p $$REDIS_CLUSTER_PORT cluster addslots $$(seq 0 16383)
elif [ "$$assigned" != "16384" ]; then
echo "Unexpected partial Redis Cluster slot assignment: $$assigned" >&2
exit 1
fi
restart: "no"