update dockerfile
This commit is contained in:
parent
043ad4c48d
commit
c4f04e88e0
@ -1,13 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
docker pull bitnami/kafka
|
||||
docker pull harisekhon/kafka
|
||||
|
||||
docker stop kafka
|
||||
|
||||
docker rm kafka
|
||||
|
||||
docker run -d --name kafka \
|
||||
--network app-tier \
|
||||
-e ALLOW_PLAINTEXT_LISTENER=yes \
|
||||
-e KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper-server:2181 \
|
||||
bitnami/kafka:latest
|
||||
docker run -dit --name kafka \
|
||||
-p 2182:2181 -p 9092:9092 \
|
||||
harisekhon/kafka:latest
|
||||
|
37
redis/Dockerfile
Normal file
37
redis/Dockerfile
Normal file
@ -0,0 +1,37 @@
|
||||
FROM debian:10
|
||||
|
||||
ENV HOME /root
|
||||
ENV DEBIAN_FRONTEND noninteractive
|
||||
|
||||
RUN sed -i s@/deb.debian.org/@/mirrors.aliyun.com/@g /etc/apt/sources.list ; sed -i s@/security.debian.org/@/mirrors.aliyun.com/@g /etc/apt/sources.list
|
||||
|
||||
RUN apt-get update -qq && \
|
||||
apt-get install --no-install-recommends -yqq \
|
||||
net-tools supervisor ruby rubygems locales gettext-base wget gcc make g++ build-essential libc6-dev tcl vim && \
|
||||
apt-get clean -yqq
|
||||
|
||||
ARG redis_version=6.2
|
||||
|
||||
RUN wget -qO redis.tar.gz https://github.com/redis/redis/tarball/${redis_version} \
|
||||
&& tar xfz redis.tar.gz -C / \
|
||||
&& mv /redis-* /redis
|
||||
|
||||
|
||||
RUN (cd /redis && make && make install)
|
||||
|
||||
RUN mkdir /redis-conf && mkdir /redis-data && rm /redis.tar.gz
|
||||
COPY redis-cluster.tmpl /redis-conf/redis-cluster.tmpl
|
||||
COPY redis.tmpl /redis-conf/redis.tmpl
|
||||
|
||||
# Add startup script
|
||||
COPY docker-entrypoint.sh /docker-entrypoint.sh
|
||||
|
||||
COPY generate-supervisor-conf.sh /generate-supervisor-conf.sh
|
||||
|
||||
|
||||
RUN chmod 755 /docker-entrypoint.sh
|
||||
|
||||
EXPOSE 7000 7001 7002 7003 7004 7005 7006 7007 5000 5001 5002
|
||||
|
||||
ENTRYPOINT ["/docker-entrypoint.sh"]
|
||||
CMD ["redis-cluster"]
|
9
redis/build.sh
Executable file
9
redis/build.sh
Executable file
@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
docker stop redis-cluster
|
||||
|
||||
docker rm redis-cluster
|
||||
|
||||
docker run -dit --name="redis-cluster" -e "IP=0.0.0.0" -p 7000-7005:7000-7005 redis-cluster:6.2
|
||||
|
||||
|
96
redis/docker-entrypoint.sh
Executable file
96
redis/docker-entrypoint.sh
Executable file
@ -0,0 +1,96 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if [ "$1" = 'redis-cluster' ]; then
|
||||
# Allow passing in cluster IP by argument or environmental variable
|
||||
IP="${2:-$IP}"
|
||||
|
||||
if [ -z "$IP" ]; then # If IP is unset then discover it
|
||||
IP=$(hostname -I)
|
||||
fi
|
||||
|
||||
echo " -- IP Before trim: '$IP'"
|
||||
IP=$(echo ${IP}) # trim whitespaces
|
||||
echo " -- IP Before split: '$IP'"
|
||||
IP=${IP%% *} # use the first ip
|
||||
echo " -- IP After trim: '$IP'"
|
||||
|
||||
if [ -z "$INITIAL_PORT" ]; then # Default to port 7000
|
||||
INITIAL_PORT=7000
|
||||
fi
|
||||
|
||||
if [ -z "$MASTERS" ]; then # Default to 3 masters
|
||||
MASTERS=3
|
||||
fi
|
||||
|
||||
if [ -z "$SLAVES_PER_MASTER" ]; then # Default to 1 slave for each master
|
||||
SLAVES_PER_MASTER=1
|
||||
fi
|
||||
|
||||
if [ -z "$BIND_ADDRESS" ]; then # Default to any IPv4 address
|
||||
BIND_ADDRESS=0.0.0.0
|
||||
fi
|
||||
|
||||
max_port=$(($INITIAL_PORT + $MASTERS * ( $SLAVES_PER_MASTER + 1 ) - 1))
|
||||
first_standalone=$(($max_port + 1))
|
||||
if [ "$STANDALONE" = "true" ]; then
|
||||
STANDALONE=2
|
||||
fi
|
||||
if [ ! -z "$STANDALONE" ]; then
|
||||
max_port=$(($max_port + $STANDALONE))
|
||||
fi
|
||||
|
||||
for port in $(seq $INITIAL_PORT $max_port); do
|
||||
mkdir -p /redis-conf/${port}
|
||||
mkdir -p /redis-data/${port}
|
||||
|
||||
if [ -e /redis-data/${port}/nodes.conf ]; then
|
||||
rm /redis-data/${port}/nodes.conf
|
||||
fi
|
||||
|
||||
if [ -e /redis-data/${port}/dump.rdb ]; then
|
||||
rm /redis-data/${port}/dump.rdb
|
||||
fi
|
||||
|
||||
if [ -e /redis-data/${port}/appendonly.aof ]; then
|
||||
rm /redis-data/${port}/appendonly.aof
|
||||
fi
|
||||
|
||||
if [ "$port" -lt "$first_standalone" ]; then
|
||||
PORT=${port} BIND_ADDRESS=${BIND_ADDRESS} envsubst < /redis-conf/redis-cluster.tmpl > /redis-conf/${port}/redis.conf
|
||||
nodes="$nodes $IP:$port"
|
||||
else
|
||||
PORT=${port} BIND_ADDRESS=${BIND_ADDRESS} envsubst < /redis-conf/redis.tmpl > /redis-conf/${port}/redis.conf
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
bash /generate-supervisor-conf.sh $INITIAL_PORT $max_port > /etc/supervisor/supervisord.conf
|
||||
|
||||
supervisord -c /etc/supervisor/supervisord.conf
|
||||
sleep 3
|
||||
|
||||
#
|
||||
## Check the version of redis-cli and if we run on a redis server below 5.0
|
||||
## If it is below 5.0 then we use the redis-trib.rb to build the cluster
|
||||
#
|
||||
/redis/src/redis-cli --version | grep -E "redis-cli 3.0|redis-cli 3.2|redis-cli 4.0"
|
||||
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
echo "Using old redis-trib.rb to create the cluster"
|
||||
echo "yes" | eval ruby /redis/src/redis-trib.rb create --replicas "$SLAVES_PER_MASTER" "$nodes"
|
||||
else
|
||||
echo "Using redis-cli to create the cluster"
|
||||
echo "yes" | eval /redis/src/redis-cli --cluster create --cluster-replicas "$SLAVES_PER_MASTER" "$nodes"
|
||||
fi
|
||||
|
||||
if [ "$SENTINEL" = "true" ]; then
|
||||
for port in $(seq $INITIAL_PORT $(($INITIAL_PORT + $MASTERS))); do
|
||||
redis-sentinel /redis-conf/sentinel-${port}.conf &
|
||||
done
|
||||
fi
|
||||
|
||||
tail -f /var/log/supervisor/redis*.log
|
||||
else
|
||||
exec "$@"
|
||||
fi
|
45
redis/generate-supervisor-conf.sh
Executable file
45
redis/generate-supervisor-conf.sh
Executable file
@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
initial_port="$1"
|
||||
max_port="$2"
|
||||
|
||||
program_entry_template ()
|
||||
{
|
||||
local count=$1
|
||||
local port=$2
|
||||
echo "
|
||||
[program:redis-$count]
|
||||
command=/redis/src/redis-server /redis-conf/$port/redis.conf
|
||||
stdout_logfile=/var/log/supervisor/%(program_name)s.log
|
||||
stderr_logfile=/var/log/supervisor/%(program_name)s.log
|
||||
autorestart=true
|
||||
"
|
||||
}
|
||||
|
||||
result_str="
|
||||
[unix_http_server]
|
||||
file=/tmp/supervisor.sock ; path to your socket file
|
||||
[supervisord]
|
||||
logfile=/supervisord.log ; supervisord log file
|
||||
logfile_maxbytes=50MB ; maximum size of logfile before rotation
|
||||
logfile_backups=10 ; number of backed up logfiles
|
||||
loglevel=error ; info, debug, warn, trace
|
||||
pidfile=/var/run/supervisord.pid ; pidfile location
|
||||
nodaemon=false ; run supervisord as a daemon
|
||||
minfds=1024 ; number of startup file descriptors
|
||||
minprocs=200 ; number of process descriptors
|
||||
user=root ; default user
|
||||
childlogdir=/ ; where child log files will live
|
||||
[rpcinterface:supervisor]
|
||||
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
|
||||
[supervisorctl]
|
||||
serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket
|
||||
"
|
||||
|
||||
count=1
|
||||
for port in `seq $initial_port $max_port`; do
|
||||
result_str="$result_str$(program_entry_template $count $port)"
|
||||
count=$((count + 1))
|
||||
done
|
||||
|
||||
echo "$result_str"
|
8
redis/redis-cluster.tmpl
Normal file
8
redis/redis-cluster.tmpl
Normal file
@ -0,0 +1,8 @@
|
||||
bind ${BIND_ADDRESS}
|
||||
port ${PORT}
|
||||
cluster-enabled yes
|
||||
cluster-config-file nodes.conf
|
||||
cluster-node-timeout 5000
|
||||
appendonly yes
|
||||
dir /redis-data/${PORT}
|
||||
appendonly no
|
4
redis/redis.tmpl
Normal file
4
redis/redis.tmpl
Normal file
@ -0,0 +1,4 @@
|
||||
bind ${BIND_ADDRESS}
|
||||
port ${PORT}
|
||||
appendonly no
|
||||
dir /redis-data/${PORT}
|
@ -1,12 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
docker pull bitnami/zookeeper
|
||||
docker pull harisekhon/zookeeper
|
||||
|
||||
docker stop zookeeper-server
|
||||
|
||||
docker rm zookeeper-server
|
||||
|
||||
docker run -d --name zookeeper-server \
|
||||
--network app-tier \
|
||||
-e ALLOW_ANONYMOUS_LOGIN=yes \
|
||||
bitnami/zookeeper:latest
|
||||
docker run -dit --name zookeeper-server \
|
||||
-p 2181:2181 -p 3181:3181 -p 4181:4181 \
|
||||
harisekhon/zookeeper
|
||||
|
Loading…
Reference in New Issue
Block a user