diff --git a/Dockerfile b/Dockerfile index fb576bc354c2ef02252743b1b876ce847c78b556..23bb38b25a7ff30d980c78c1b380e1d442725df9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -41,10 +41,14 @@ COPY setupMasterSlave.sh /usr/bin/setupMasterSlave.sh COPY healthcheck.sh /usr/bin/healthcheck.sh +RUN chown -R redis:redis /etc/redis + VOLUME ["/data"] WORKDIR /data EXPOSE 6379 +USER 1000 + ENTRYPOINT ["/usr/bin/entrypoint.sh"] diff --git a/entrypoint.sh b/entrypoint.sh index 590e9cee4043bfb8a49510ca7688d428340c1e75..f582657945852836df3ac1e530fa9e7678186a7d 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -19,10 +19,12 @@ common_operation() { set_redis_password() { if [[ -z "${REDIS_PASSWORD}" ]]; then echo "Redis is running without password which is not recommended" + echo "protected-mode no" >> /etc/redis/redis.conf else { echo masterauth "${REDIS_PASSWORD}" echo requirepass "${REDIS_PASSWORD}" + echo protected-mode yes } >> /etc/redis/redis.conf fi } @@ -37,12 +39,8 @@ redis_mode_setup() { echo cluster-config-file "${DATA_DIR}/nodes.conf" } >> /etc/redis/redis.conf - if [[ "${REDIS_MAJOR_VERSION}" != "v7" ]]; then - if [[ -z "${POD_IP}" ]]; then - POD_IP=$(hostname -i) - fi - sed -i -e "/myself/ s/[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}/${POD_IP}/" "${DATA_DIR}/nodes.conf" - fi + POD_IP=$(hostname -i) + sed -i -e "/myself/ s/[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}/${POD_IP}/" "${DATA_DIR}/nodes.conf" else echo "Setting up redis in standalone mode" fi diff --git a/redis.conf b/redis.conf index ddfa5405bc1754322afb018c58f967cddc639cd5..0097fa9e31ae6a98cc988a39440111edd2e6cbbf 100755 --- a/redis.conf +++ b/redis.conf @@ -1,5 +1,4 @@ bind 0.0.0.0 -protected-mode yes tcp-backlog 511 timeout 0 tcp-keepalive 300