diff options
-rw-r--r-- | docker/base/Dockerfile.cluster | 2 | ||||
-rw-r--r-- | docker/base/Dockerfile.unstable_cluster | 9 | ||||
-rw-r--r-- | docker/base/create_cluster.sh | 6 | ||||
-rw-r--r-- | docker/unstable_cluster/redis.conf | 4 | ||||
-rw-r--r-- | tox.ini | 14 |
5 files changed, 32 insertions, 3 deletions
diff --git a/docker/base/Dockerfile.cluster b/docker/base/Dockerfile.cluster index 70df5ba..5d41980 100644 --- a/docker/base/Dockerfile.cluster +++ b/docker/base/Dockerfile.cluster @@ -6,4 +6,4 @@ RUN chmod +x /create_cluster.sh EXPOSE 16379 16380 16381 16382 16383 16384 -CMD [ "/create_cluster.sh"] +CMD /create_cluster.sh 16379 16384 diff --git a/docker/base/Dockerfile.unstable_cluster b/docker/base/Dockerfile.unstable_cluster new file mode 100644 index 0000000..31e4275 --- /dev/null +++ b/docker/base/Dockerfile.unstable_cluster @@ -0,0 +1,9 @@ +# produces redisfab/redis-py-cluster:6.2.6 +FROM redisfab/redis-py:unstable-bionic + +COPY create_cluster.sh /create_cluster.sh +RUN chmod +x /create_cluster.sh + +EXPOSE 6372 6373 6374 6375 6376 6377 + +CMD /create_cluster.sh 6372 6377 diff --git a/docker/base/create_cluster.sh b/docker/base/create_cluster.sh index 82a79c8..7233294 100644 --- a/docker/base/create_cluster.sh +++ b/docker/base/create_cluster.sh @@ -1,7 +1,9 @@ #! /bin/bash mkdir -p /nodes touch /nodes/nodemap -for PORT in $(seq 16379 16384); do +START_NODE=$1 +END_NODE=$2 +for PORT in `seq ${START_NODE} ${END_NODE}`; do mkdir -p /nodes/$PORT if [[ -e /redis.conf ]]; then cp /redis.conf /nodes/$PORT/redis.conf @@ -22,5 +24,5 @@ EOF fi echo 127.0.0.1:$PORT >> /nodes/nodemap done -echo yes | redis-cli --cluster create $(seq -f 127.0.0.1:%g 16379 16384) --cluster-replicas 1 +echo yes | redis-cli --cluster create $(seq -f 127.0.0.1:%g ${START_NODE} ${END_NODE}) --cluster-replicas 1 tail -f /redis.log diff --git a/docker/unstable_cluster/redis.conf b/docker/unstable_cluster/redis.conf new file mode 100644 index 0000000..f307a63 --- /dev/null +++ b/docker/unstable_cluster/redis.conf @@ -0,0 +1,4 @@ +# Redis Cluster config file will be shared across all nodes. +# Do not change the following configurations that are already set: +# port, cluster-enabled, daemonize, logfile, dir +protected-mode no @@ -41,6 +41,19 @@ healtcheck_cmd = python -c "import socket;print(True) if 0 == socket.socket(sock volumes = bind:rw:{toxinidir}/docker/unstable/redis.conf:/redis.conf +[docker:unstable_cluster] +name = unstable_cluster +image = redisfab/redis-py-cluster:unstable-bionic +ports = + 6372:6372/tcp + 6373:6373/tcp + 6374:6374/tcp + 6375:6375/tcp + 6376:6376/tcp + 6377:6377/tcp +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" +volumes = + bind:rw:{toxinidir}/docker/cluster/redis.conf:/redis.conf [docker:sentinel_1] name = sentinel_1 @@ -118,6 +131,7 @@ deps = -r {toxinidir}/dev_requirements.txt docker = unstable + unstable_cluster master replica sentinel_1 |