wwfortunate
1/10/2018 - 6:06 AM

Redis docker image

Redis docker image

#!/bin/bash   
config=""
if [ ! "$port" = "" ];  
then  
   config='port '$port;
else
   config='port 6379'
fi
if [ ! "$maxmemory" = "" ];
then 
   config=$config'\nmaxmemory '$maxmemory;
else
   config=$config'\nmaxmemory 2gb';
fi
if [ ! "$password" = "" ];
then 
   config=$config'\nrequirepass '$password;
fi
if [ ! "$databases" = "" ];
then
   config=$config'\ndatabases '$databases;
fi
if [ ! "$slaveof" = "" ];
then 
   config=$config'\nslaveof '$slaveof;
fi
if [ ! "$masterauth" = "" ];
then
   config=$config'\nmasterauth '$masterauth;
fi

config=$config'\ntcp-backlog 511';
config=$config'\ntimeout 0';
config=$config'\nsave ""';
config=$config'\nslowlog-log-slower-than 200000';
config=$config'\nslowlog-max-len 1000';
config=$config'\ntcp-keepalive 60';
config=$config'\nmaxmemory-policy allkeys-lru'
config=$config'\nrename-command keys tckeys'
config=$config'\nprotected-mode no'




if [ "$redistype" = "cluster" ]
then
   config=$config'\ncluster-require-full-coverage no'
   config=$config'\ncluster-enabled yes'
   config=$config'\ncluster-slave-validity-factor 0'
fi

if [ ! -f "/data/redis.conf" ]; then 
   echo -e $config>/data/redis.conf
fi

redis-server /data/redis.conf
### redis-standealone:

port 6379
maxmemory 2gb
tcp-backlog 511
timeout 0
save ""
slowlog-log-slower-than 200000
slowlog-max-len 1000
tcp-keepalive 60
maxmemory-policy allkeys-lru
rename-command keys mykeys
protected-mode no

### redis-cluster:

port 6379
maxmemory 2gb
tcp-backlog 511
timeout 0
save ""
slowlog-log-slower-than 200000
slowlog-max-len 1000
tcp-keepalive 60
maxmemory-policy allkeys-lru
rename-command keys tckeys
protected-mode no
cluster-require-full-coverage no
cluster-enabled yes
cluster-slave-validity-factor 0
FROM docker.io/redis:4.0.2-alpine
ADD  ./ /data/
WORKDIR /data
CMD  sh /data/redis_init