From b2b4306b62cbbddc7f6f8dbeb6c4d55a121b581a Mon Sep 17 00:00:00 2001 From: yangw Date: Fri, 8 Dec 2023 14:43:05 +0800 Subject: [PATCH] Support custom redis port (#62) Signed-off-by: drivebyer --- Dockerfile | 4 +++- entrypoint.sh | 7 +++++++ healthcheck.sh | 4 ++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index ede992f..7cd39e6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,6 +30,8 @@ LABEL maintainer="Opstree Solutions" ARG TARGETARCH +ENV REDIS_PORT=6379 + LABEL version=1.0 \ arch=$TARGETARCH \ description="A production grade performance tuned redis docker image created by Opstree Solutions" @@ -62,7 +64,7 @@ VOLUME ["/node-conf"] WORKDIR /data -EXPOSE 6379 +EXPOSE ${REDIS_PORT} USER 1000 diff --git a/entrypoint.sh b/entrypoint.sh index 3b6f1d2..792bc1d 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -99,6 +99,12 @@ persistence_setup() { fi } +port_setup() { + { + echo port "${REDIS_PORT}" + } >> /etc/redis/redis.conf +} + external_config() { echo "include ${EXTERNAL_CONFIG_FILE}" >> /etc/redis/redis.conf } @@ -139,6 +145,7 @@ main_function() { persistence_setup tls_setup acl_setup + port_setup if [[ -f "${EXTERNAL_CONFIG_FILE}" ]]; then external_config fi diff --git a/healthcheck.sh b/healthcheck.sh index 2b8166c..bda0509 100755 --- a/healthcheck.sh +++ b/healthcheck.sh @@ -5,9 +5,9 @@ check_redis_health() { export REDISCLI_AUTH="${REDIS_PASSWORD}" fi if [[ "${TLS_MODE}" == "true" ]]; then - redis-cli --tls --cert "${REDIS_TLS_CERT}" --key "${REDIS_TLS_CERT_KEY}" --cacert "${REDIS_TLS_CA_KEY}" -h "$(hostname)" ping + redis-cli --tls --cert "${REDIS_TLS_CERT}" --key "${REDIS_TLS_CERT_KEY}" --cacert "${REDIS_TLS_CA_KEY}" -h "$(hostname)" -p "${REDIS_PORT}" ping else - redis-cli -h "$(hostname)" ping + redis-cli -h "$(hostname)" -p "${REDIS_PORT}" ping fi }