Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redismod cluster docker #2022

Merged
merged 4 commits into from
Mar 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docker/base/Dockerfile.redismod_cluster
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# produces redisfab/redis-py-modcluster:6.2.6
FROM redislabs/redismod:edge

COPY create_redismod_cluster.sh /create_redismod_cluster.sh
RUN chmod +x /create_redismod_cluster.sh

EXPOSE 46379 46380 46381 46382 46383 46384

ENV START_PORT=46379
ENV END_PORT=46384
ENTRYPOINT []
CMD /create_redismod_cluster.sh
46 changes: 46 additions & 0 deletions docker/base/create_redismod_cluster.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#! /bin/bash

mkdir -p /nodes
touch /nodes/nodemap
if [ -z ${START_PORT} ]; then
START_PORT=46379
fi
if [ -z ${END_PORT} ]; then
END_PORT=46384
fi
if [ ! -z "$3" ]; then
START_PORT=$2
START_PORT=$3
fi
echo "STARTING: ${START_PORT}"
echo "ENDING: ${END_PORT}"

for PORT in `seq ${START_PORT} ${END_PORT}`; do
mkdir -p /nodes/$PORT
if [[ -e /redis.conf ]]; then
cp /redis.conf /nodes/$PORT/redis.conf
else
touch /nodes/$PORT/redis.conf
fi
cat << EOF >> /nodes/$PORT/redis.conf
port ${PORT}
cluster-enabled yes
daemonize yes
logfile /redis.log
dir /nodes/$PORT
EOF

set -x
redis-server /nodes/$PORT/redis.conf
if [ $? -ne 0 ]; then
echo "Redis failed to start, exiting."
continue
fi
echo 127.0.0.1:$PORT >> /nodes/nodemap
done
if [ -z "${REDIS_PASSWORD}" ]; then
echo yes | redis-cli --cluster create `seq -f 127.0.0.1:%g ${START_PORT} ${END_PORT}` --cluster-replicas 1
else
echo yes | redis-cli -a ${REDIS_PASSWORD} --cluster create `seq -f 127.0.0.1:%g ${START_PORT} ${END_PORT}` --cluster-replicas 1
fi
tail -f /redis.log
8 changes: 8 additions & 0 deletions docker/redismod_cluster/redis.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
loadmodule /usr/lib/redis/modules/redisai.so
loadmodule /usr/lib/redis/modules/redisearch.so
loadmodule /usr/lib/redis/modules/redisgraph.so
loadmodule /usr/lib/redis/modules/redistimeseries.so
loadmodule /usr/lib/redis/modules/rejson.so
loadmodule /usr/lib/redis/modules/redisbloom.so
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/

15 changes: 15 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,20 @@ healtcheck_cmd = python -c "import socket;print(True) if all([0 == socket.socket
volumes =
bind:rw:{toxinidir}/docker/cluster/redis.conf:/redis.conf

[docker:redismod_cluster]
name = redismod_cluster
image = redisfab/redis-py-modcluster:6.2.6
ports =
46379:46379/tcp
46380:46380/tcp
46381:46381/tcp
46382:46382/tcp
46383:46383/tcp
46384:46384/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(46379,46384)]) else False"
volumes =
bind:rw:{toxinidir}/docker/redismod_cluster/redis.conf:/redis.conf

[docker:stunnel]
name = stunnel
image = redisfab/stunnel:latest
Expand Down Expand Up @@ -262,6 +276,7 @@ docker =
sentinel_3
redis_cluster
redismod
redismod_cluster
stunnel
extras =
hiredis: hiredis
Expand Down