Commit 4eb86fc2 authored by iamabhishek-dubey's avatar iamabhishek-dubey

Added entrypoint.sh to support cluster and standalone

parent a44b9b24
FROM alpine:3.9
MAINTAINER Opstree Solutions
LABEL VERSION=1.0 \
ARCH=AMD64 \
DESCRIPTION="A production grade performance tuned docker image created by Opstree Solutions"
ARG REDIS_DOWNLOAD_URL="http://download.redis.io/"
ARG REDIS_VERSION="stable"
COPY redis.conf /etc/redis/redis.conf
COPY entrypoint.sh /usr/bin/entrypoint.sh
RUN addgroup -S -g 1000 redis && adduser -S -G redis -u 999 redis && \
apk add --no-cache su-exec tzdata make curl build-base linux-headers
RUN curl -fL -Lo /tmp/redis-${REDIS_VERSION}.tar.gz ${REDIS_DOWNLOAD_URL}/redis-${REDIS_VERSION}.tar.gz && \
cd /tmp && \
tar xvzf redis-${REDIS_VERSION}.tar.gz && \
cd redis-${REDIS_VERSION} && \
make && \
make install && \
mkdir -p /etc/redis && \
cp -f *.conf /etc/redis && \
rm -rf /tmp/redis-${REDIS_VERSION}*
VOLUME ["/data"]
WORKDIR /data
EXPOSE 6379
ENTRYPOINT ["/usr/bin/entrypoint.sh"]
#!/bin/sh
set -eu
set_redis_password() {
if [ -z "${REDIS_PASSWORD}" ]; then
echo "Redis is running without password which is not recommended"
else
{
echo masterauth "${REDIS_PASSWORD}"
echo requirepass "${REDIS_PASSWORD}"
} >> /etc/redis/redis.conf
fi
}
redis_mode_setup() {
if [ "${SETUP_MODE}" = "cluster" ]; then
{
echo cluster-enabled yes
echo cluster-config-file nodes.conf
echo cluster-node-timeout 5000
} >> /etc/redis/redis.conf
else
echo "Setting up redis in standalone mode"
fi
}
start_redis() {
echo "Starting redis service "
redis-server /etc/redis/redis.conf
}
main_function() {
set_redis_password
redis_mode_setup
start_redis
}
main_function
bind 0.0.0.0
protected-mode yes
tcp-backlog 511
timeout 0
tcp-keepalive 300
daemonize no
supervised no
pidfile /var/run/redis.pid
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment