Skip to content

Commit 87764e7

Browse files
chayimdvora-h
andauthored
redismod cluster docker (#2022)
* redismod cluster docker * add to tox * mod cluster Co-authored-by: dvora-h <[email protected]>
1 parent d33ff44 commit 87764e7

File tree

4 files changed

+81
-0
lines changed

4 files changed

+81
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# produces redisfab/redis-py-modcluster:6.2.6
2+
FROM redislabs/redismod:edge
3+
4+
COPY create_redismod_cluster.sh /create_redismod_cluster.sh
5+
RUN chmod +x /create_redismod_cluster.sh
6+
7+
EXPOSE 46379 46380 46381 46382 46383 46384
8+
9+
ENV START_PORT=46379
10+
ENV END_PORT=46384
11+
ENTRYPOINT []
12+
CMD /create_redismod_cluster.sh
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#! /bin/bash
2+
3+
mkdir -p /nodes
4+
touch /nodes/nodemap
5+
if [ -z ${START_PORT} ]; then
6+
START_PORT=46379
7+
fi
8+
if [ -z ${END_PORT} ]; then
9+
END_PORT=46384
10+
fi
11+
if [ ! -z "$3" ]; then
12+
START_PORT=$2
13+
START_PORT=$3
14+
fi
15+
echo "STARTING: ${START_PORT}"
16+
echo "ENDING: ${END_PORT}"
17+
18+
for PORT in `seq ${START_PORT} ${END_PORT}`; do
19+
mkdir -p /nodes/$PORT
20+
if [[ -e /redis.conf ]]; then
21+
cp /redis.conf /nodes/$PORT/redis.conf
22+
else
23+
touch /nodes/$PORT/redis.conf
24+
fi
25+
cat << EOF >> /nodes/$PORT/redis.conf
26+
port ${PORT}
27+
cluster-enabled yes
28+
daemonize yes
29+
logfile /redis.log
30+
dir /nodes/$PORT
31+
EOF
32+
33+
set -x
34+
redis-server /nodes/$PORT/redis.conf
35+
if [ $? -ne 0 ]; then
36+
echo "Redis failed to start, exiting."
37+
continue
38+
fi
39+
echo 127.0.0.1:$PORT >> /nodes/nodemap
40+
done
41+
if [ -z "${REDIS_PASSWORD}" ]; then
42+
echo yes | redis-cli --cluster create `seq -f 127.0.0.1:%g ${START_PORT} ${END_PORT}` --cluster-replicas 1
43+
else
44+
echo yes | redis-cli -a ${REDIS_PASSWORD} --cluster create `seq -f 127.0.0.1:%g ${START_PORT} ${END_PORT}` --cluster-replicas 1
45+
fi
46+
tail -f /redis.log

docker/redismod_cluster/redis.conf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
loadmodule /usr/lib/redis/modules/redisai.so
2+
loadmodule /usr/lib/redis/modules/redisearch.so
3+
loadmodule /usr/lib/redis/modules/redisgraph.so
4+
loadmodule /usr/lib/redis/modules/redistimeseries.so
5+
loadmodule /usr/lib/redis/modules/rejson.so
6+
loadmodule /usr/lib/redis/modules/redisbloom.so
7+
loadmodule /var/opt/redislabs/lib/modules/redisgears.so Plugin /var/opt/redislabs/modules/rg/plugin/gears_python.so Plugin /var/opt/redislabs/modules/rg/plugin/gears_jvm.so JvmOptions -Djava.class.path=/var/opt/redislabs/modules/rg/gear_runtime-jar-with-dependencies.jar JvmPath /var/opt/redislabs/modules/rg/OpenJDK/jdk-11.0.9.1+1/
8+

tox.ini

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,20 @@ healtcheck_cmd = python -c "import socket;print(True) if all([0 == socket.socket
109109
volumes =
110110
bind:rw:{toxinidir}/docker/cluster/redis.conf:/redis.conf
111111

112+
[docker:redismod_cluster]
113+
name = redismod_cluster
114+
image = redisfab/redis-py-modcluster:6.2.6
115+
ports =
116+
46379:46379/tcp
117+
46380:46380/tcp
118+
46381:46381/tcp
119+
46382:46382/tcp
120+
46383:46383/tcp
121+
46384:46384/tcp
122+
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(46379,46384)]) else False"
123+
volumes =
124+
bind:rw:{toxinidir}/docker/redismod_cluster/redis.conf:/redis.conf
125+
112126
[docker:stunnel]
113127
name = stunnel
114128
image = redisfab/stunnel:latest
@@ -262,6 +276,7 @@ docker =
262276
sentinel_3
263277
redis_cluster
264278
redismod
279+
redismod_cluster
265280
stunnel
266281
extras =
267282
hiredis: hiredis

0 commit comments

Comments
 (0)