Skip to content

Commit fa5841e

Browse files
authored
redis-unstable cluster docker (#1889)
1 parent 4765298 commit fa5841e

File tree

5 files changed

+32
-3
lines changed

5 files changed

+32
-3
lines changed

docker/base/Dockerfile.cluster

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ RUN chmod +x /create_cluster.sh
66

77
EXPOSE 16379 16380 16381 16382 16383 16384
88

9-
CMD [ "/create_cluster.sh"]
9+
CMD /create_cluster.sh 16379 16384
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# produces redisfab/redis-py-cluster:6.2.6
2+
FROM redisfab/redis-py:unstable-bionic
3+
4+
COPY create_cluster.sh /create_cluster.sh
5+
RUN chmod +x /create_cluster.sh
6+
7+
EXPOSE 6372 6373 6374 6375 6376 6377
8+
9+
CMD /create_cluster.sh 6372 6377

docker/base/create_cluster.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#! /bin/bash
22
mkdir -p /nodes
33
touch /nodes/nodemap
4-
for PORT in $(seq 16379 16384); do
4+
START_NODE=$1
5+
END_NODE=$2
6+
for PORT in `seq ${START_NODE} ${END_NODE}`; do
57
mkdir -p /nodes/$PORT
68
if [[ -e /redis.conf ]]; then
79
cp /redis.conf /nodes/$PORT/redis.conf
@@ -22,5 +24,5 @@ EOF
2224
fi
2325
echo 127.0.0.1:$PORT >> /nodes/nodemap
2426
done
25-
echo yes | redis-cli --cluster create $(seq -f 127.0.0.1:%g 16379 16384) --cluster-replicas 1
27+
echo yes | redis-cli --cluster create $(seq -f 127.0.0.1:%g ${START_NODE} ${END_NODE}) --cluster-replicas 1
2628
tail -f /redis.log

docker/unstable_cluster/redis.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Redis Cluster config file will be shared across all nodes.
2+
# Do not change the following configurations that are already set:
3+
# port, cluster-enabled, daemonize, logfile, dir
4+
protected-mode no

tox.ini

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,19 @@ healtcheck_cmd = python -c "import socket;print(True) if 0 == socket.socket(sock
4141
volumes =
4242
bind:rw:{toxinidir}/docker/unstable/redis.conf:/redis.conf
4343

44+
[docker:unstable_cluster]
45+
name = unstable_cluster
46+
image = redisfab/redis-py-cluster:unstable-bionic
47+
ports =
48+
6372:6372/tcp
49+
6373:6373/tcp
50+
6374:6374/tcp
51+
6375:6375/tcp
52+
6376:6376/tcp
53+
6377:6377/tcp
54+
healtcheck_cmd = python -c "import socket;print(True) if all([0 == socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect_ex(('127.0.0.1',port)) for port in range(6372,6377)]) else False"
55+
volumes =
56+
bind:rw:{toxinidir}/docker/cluster/redis.conf:/redis.conf
4457

4558
[docker:sentinel_1]
4659
name = sentinel_1
@@ -118,6 +131,7 @@ deps =
118131
-r {toxinidir}/dev_requirements.txt
119132
docker =
120133
unstable
134+
unstable_cluster
121135
master
122136
replica
123137
sentinel_1

0 commit comments

Comments
 (0)