diff --git a/Dockerfile.sentinel b/Dockerfile.sentinel new file mode 100644 index 0000000000000000000000000000000000000000..f4ff51057163a5a381d5d6241039c8645e839969 --- /dev/null +++ b/Dockerfile.sentinel @@ -0,0 +1,49 @@ +FROM alpine:3.15 as builder + +LABEL VERSION=1.0 \ + ARCH=AMD64 \ + DESCRIPTION="A production grade performance tuned redis docker image created by Opstree Solutions" + +ARG REDIS_DOWNLOAD_URL="http://download.redis.io/" + +ARG REDIS_VERSION="stable" + +RUN apk add --no-cache su-exec tzdata make curl build-base linux-headers bash openssl-dev + +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 BUILD_TLS=yes + +FROM alpine:3.15 + +LABEL VERSION=1.0 \ + ARCH=AMD64 \ + DESCRIPTION="A production grade performance tuned redis docker image created by Opstree Solutions" + + +COPY --from=builder /usr/local/bin/redis-cli /usr/local/bin/redis-cli +COPY --from=builder /usr/local/bin/redis-sentinel /usr/local/bin/redis-sentinel + +RUN addgroup -S -g 1000 redis && adduser -S -G redis -u 1000 redis && \ + apk add --no-cache bash + +COPY sentinel.conf /etc/redis/sentinel.conf + +COPY entrypoint-sentinel.sh /usr/bin/entrypoint-sentinel.sh + +COPY healthcheck.sh /usr/bin/healthcheck.sh + +RUN chown -R redis:redis /etc/redis + +VOLUME ["/sentinel-data"] + +WORKDIR /data + +EXPOSE 26379 + +USER 1000 + +ENTRYPOINT ["/usr/bin/entrypoint-sentinel.sh"] diff --git a/entrypoint-sentinel.sh b/entrypoint-sentinel.sh new file mode 100644 index 0000000000000000000000000000000000000000..9f66968a76e2f03132e74875942b423d3a58553d --- /dev/null +++ b/entrypoint-sentinel.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +EXTERNAL_CONFIG_FILE=${EXTERNAL_CONFIG_FILE:-"/etc/redis/external.conf.d/redis-sentinel-additional.conf"} + +external_config() { + echo "include ${EXTERNAL_CONFIG_FILE}" >> /etc/redis/sentinel.conf +} + +start_sentinel() { + + echo "Starting redis sentinel service in standalone mode....." + redis-sentinel /etc/redis/sentinel.conf + +} + +main_function() { + + if [[ -f "${EXTERNAL_CONFIG_FILE}" ]]; then + external_config + fi + start_sentinel +} + +main_function \ No newline at end of file diff --git a/sentine.conf b/sentine.conf new file mode 100644 index 0000000000000000000000000000000000000000..39162f3eacb2cc82864887236d3dbfe7bd81aaf2 --- /dev/null +++ b/sentine.conf @@ -0,0 +1,17 @@ +protected-mode no +port 26379 +daemonize no +pidfile /var/run/redis-sentinel.pid +logfile "" +dir /tmp + +acllog-max-len 128 + +# sentinel monitor mymaster 127.0.0.1 6379 2 +# sentinel down-after-milliseconds mymaster 30000 +# sentinel parallel-syncs mymaster 1 +# sentinel failover-timeout mymaster 180000 +sentinel deny-scripts-reconfig yes +SENTINEL resolve-hostnames no +SENTINEL announce-hostnames no +# SENTINEL master-reboot-down-after-period mymaster 0