From ccfaf58de7a098d70621308b6fd8f4920290c7fe Mon Sep 17 00:00:00 2001 From: Bitnami Bot Date: Thu, 9 Apr 2020 11:27:04 +0000 Subject: [PATCH] 5.0.8-debian-10-r35 release --- bitnami/redis/5.0/debian-10/Dockerfile | 2 +- .../prebuildfs/opt/bitnami/scripts/libnet.sh | 25 ++++++ .../rootfs/opt/bitnami/scripts/libredis.sh | 76 ++++++++++++++----- bitnami/redis/README.md | 14 ++-- 4 files changed, 94 insertions(+), 23 deletions(-) diff --git a/bitnami/redis/5.0/debian-10/Dockerfile b/bitnami/redis/5.0/debian-10/Dockerfile index dba0cbaa2e10..23262f6277b6 100644 --- a/bitnami/redis/5.0/debian-10/Dockerfile +++ b/bitnami/redis/5.0/debian-10/Dockerfile @@ -21,7 +21,7 @@ RUN ln -s /opt/bitnami/scripts/redis/run.sh /run.sh COPY rootfs / RUN /opt/bitnami/scripts/redis/postunpack.sh ENV BITNAMI_APP_NAME="redis" \ - BITNAMI_IMAGE_VERSION="5.0.8-debian-10-r34" \ + BITNAMI_IMAGE_VERSION="5.0.8-debian-10-r35" \ NAMI_PREFIX="/.nami" \ PATH="/opt/bitnami/common/bin:/opt/bitnami/redis/bin:/opt/bitnami/common/bin:$PATH" diff --git a/bitnami/redis/5.0/debian-10/prebuildfs/opt/bitnami/scripts/libnet.sh b/bitnami/redis/5.0/debian-10/prebuildfs/opt/bitnami/scripts/libnet.sh index e3145b134ece..6cb749858648 100644 --- a/bitnami/redis/5.0/debian-10/prebuildfs/opt/bitnami/scripts/libnet.sh +++ b/bitnami/redis/5.0/debian-10/prebuildfs/opt/bitnami/scripts/libnet.sh @@ -21,6 +21,31 @@ dns_lookup() { getent ahosts "$host" | awk '/STREAM/ {print $1 }' } +######################### +## Wait for a hostname and return the IP +# Arguments: +# $1 - hostname +# $2 - number of retries +# $3 - seconds to wait between retries +# Returns: +# - IP address that corresponds to the hostname +######################### +wait_for_dns_lookup() { + local hostname="${1:?hostname is missing}" + local retries="${2:-5}" + local seconds="${3:-1}" + check_host() { + if [[ $(dns_lookup "$hostname") == "" ]]; then + false + else + true + fi + } + # Wait 10 minutes for the host to be ready + retry_while "check_host ${hostname}" "$retries" "$seconds" + dns_lookup "$hostname" +} + ######################## # Get machine's IP # Arguments: diff --git a/bitnami/redis/5.0/debian-10/rootfs/opt/bitnami/scripts/libredis.sh b/bitnami/redis/5.0/debian-10/rootfs/opt/bitnami/scripts/libredis.sh index 02ae15281139..9937144a47ff 100644 --- a/bitnami/redis/5.0/debian-10/rootfs/opt/bitnami/scripts/libredis.sh +++ b/bitnami/redis/5.0/debian-10/rootfs/opt/bitnami/scripts/libredis.sh @@ -207,6 +207,7 @@ export REDIS_MASTER_PORT_NUMBER="${REDIS_MASTER_PORT_NUMBER:-6379}" export REDIS_MASTER_PASSWORD="${REDIS_MASTER_PASSWORD:-}" export REDIS_PASSWORD="${REDIS_PASSWORD:-}" export REDIS_REPLICATION_MODE="${REDIS_REPLICATION_MODE:-}" +export REDIS_PORT="${REDIS_PORT:-6379}" export ALLOW_EMPTY_PASSWORD="${ALLOW_EMPTY_PASSWORD:-no}" EOF if [[ -f "${REDIS_PASSWORD_FILE:-}" ]]; then @@ -270,8 +271,6 @@ redis_validate() { [[ "$error_code" -eq 0 ]] || exit "$error_code" } - - ######################## # Configure Redis replication # Globals: @@ -328,6 +327,43 @@ redis_disable_unsafe_commands() { done } +######################## +# Redis configure perissions +# Globals: +# REDIS_* +# Arguments: +# None +# Returns: +# None +######################### +redis_configure_permissions() { + debug "Ensuring expected directories/files exist..." + for dir in "${REDIS_BASEDIR}" "${REDIS_VOLUME}/data" "${REDIS_BASEDIR}/tmp" "${REDIS_LOGDIR}"; do + ensure_dir_exists "$dir" + if am_i_root; then + chown "$REDIS_DAEMON_USER:$REDIS_DAEMON_GROUP" "$dir" + fi + done +} + +######################## +# Redis specific configuration to override the default one +# Globals: +# REDIS_* +# Arguments: +# None +# Returns: +# None +######################### +redis_override_conf() { + if [[ ! -e "$REDIS_BASEDIR/mounted-etc/redis.conf" ]]; then + # Configure Replication mode + if [[ -n "$REDIS_REPLICATION_MODE" ]]; then + redis_configure_replication + fi + fi +} + ######################## # Ensure Redis is initialized # Globals: @@ -338,29 +374,39 @@ redis_disable_unsafe_commands() { # None ######################### redis_initialize() { + redis_configure_default + redis_override_conf +} + +######################## +# Configures Redis permissions and general parameters (also used in redis-cluster container) +# Globals: +# REDIS_* +# Arguments: +# None +# Returns: +# None +######################### +redis_configure_default() { info "Initializing Redis..." # This fixes an issue where the trap would kill the entrypoint.sh, if a PID was left over from a previous run # Exec replaces the process without creating a new one, and when the container is restarted it may have the same PID rm -f "$REDIS_BASEDIR/tmp/redis.pid" + redis_configure_permissions + # User injected custom configuration - if [[ -e "$REDIS_BASEDIR/etc/redis.conf" ]]; then + if [[ -e "$REDIS_BASEDIR/mounted-etc/redis.conf" ]]; then if [[ -e "$REDIS_BASEDIR/etc/redis-default.conf" ]]; then rm "${REDIS_BASEDIR}/etc/redis-default.conf" fi + cp "${REDIS_BASEDIR}/mounted-etc/redis.conf" "${REDIS_BASEDIR}/etc/redis.conf" else - debug "Ensuring expected directories/files exist..." - for dir in "${REDIS_VOLUME}/data" "${REDIS_BASEDIR}/tmp" "${REDIS_LOGDIR}"; do - ensure_dir_exists "$dir" - if am_i_root; then - chown "$REDIS_DAEMON_USER:$REDIS_DAEMON_GROUP" "$dir" - fi - done - mv "$REDIS_BASEDIR/etc/redis-default.conf" "$REDIS_BASEDIR/etc/redis.conf" - - # Redis config + cp "${REDIS_BASEDIR}/etc/redis-default.conf" "${REDIS_BASEDIR}/etc/redis.conf" + # Default Redis config debug "Setting Redis config file..." + redis_conf_set port "$REDIS_PORT" redis_conf_set dir "${REDIS_VOLUME}/data" redis_conf_set logfile "" # Log to stdout redis_conf_set pidfile "${REDIS_BASEDIR}/tmp/redis.pid" @@ -380,9 +426,5 @@ redis_initialize() { if [[ -n "$REDIS_DISABLE_COMMANDS" ]]; then redis_disable_unsafe_commands fi - # Configure Replication mode - if [[ -n "$REDIS_REPLICATION_MODE" ]]; then - redis_configure_replication - fi fi } diff --git a/bitnami/redis/README.md b/bitnami/redis/README.md index c95726a103cc..3096aa29f5d7 100644 --- a/bitnami/redis/README.md +++ b/bitnami/redis/README.md @@ -46,7 +46,7 @@ Non-root container images add an extra layer of security and are generally recom Learn more about the Bitnami tagging policy and the difference between rolling tags and immutable tags [in our documentation page](https://docs.bitnami.com/containers/how-to/understand-rolling-tags-containers/). -* [`5.0-debian-10`, `5.0.8-debian-10-r34`, `5.0`, `5.0.8`, `latest` (5.0/debian-10/Dockerfile)](https://github.com/bitnami/bitnami-docker-redis/blob/5.0.8-debian-10-r34/5.0/debian-10/Dockerfile) +* [`5.0-debian-10`, `5.0.8-debian-10-r35`, `5.0`, `5.0.8`, `latest` (5.0/debian-10/Dockerfile)](https://github.com/bitnami/bitnami-docker-redis/blob/5.0.8-debian-10-r35/5.0/debian-10/Dockerfile) * [`4.0-debian-10`, `4.0.14-debian-10-r72`, `4.0`, `4.0.14` (4.0/debian-10/Dockerfile)](https://github.com/bitnami/bitnami-docker-redis/blob/4.0.14-debian-10-r72/4.0/debian-10/Dockerfile) Subscribe to project updates by watching the [bitnami/redis GitHub repo](https://github.com/bitnami/bitnami-docker-redis). @@ -362,12 +362,12 @@ The above command scales up the number of replicas to `3`. You can scale down in ## Configuration file -The image looks for configurations in `/opt/bitnami/redis/etc/redis.conf`. You can overwrite the `redis.conf` file using your own custom configuration file. +The image looks for configurations in `/opt/bitnami/redis/mounted-etc/redis.conf`. You can overwrite the `redis.conf` file using your own custom configuration file. ```bash $ docker run --name redis \ -e ALLOW_EMPTY_PASSWORD=yes \ - -v /path/to/your_redis.conf:/opt/bitnami/redis/etc/redis.conf \ + -v /path/to/your_redis.conf:/opt/bitnami/redis/mounted-etc/redis.conf \ -v /path/to/redis-data-persistence:/bitnami/redis/data \ bitnami/redis:latest ``` @@ -379,7 +379,7 @@ services: redis: ... volumes: - - /path/to/your_redis.conf:/opt/bitnami/redis/etc/redis.conf + - /path/to/your_redis.conf:/opt/bitnami/redis/mounted-etc/redis.conf - /path/to/redis-persistence:/bitnami/redis/data ... ``` @@ -465,6 +465,10 @@ $ docker-compose up redis # Notable Changes +## 5.0.8-debian-10-r24 + +- The recommended mount point to use a custom `redis.conf` changes from `/opt/bitnami/redis/etc/ ` to `/opt/bitnami/redis/mounted-etc/`. + ## 5.0.0-r0 - Starting with Redis 5.0 the command [REPLICAOF](https://redis.io/commands/replicaof) is available in favor of `SLAVEOF`. For backward compatibility with previous versions, `slave` replication mode is still supported. We encourage the use of the `REPLICAOF` command if you are using Redis 5.0. @@ -473,7 +477,7 @@ $ docker-compose up redis - Decrease the size of the container. It is not necessary Node.js anymore. Redis configuration moved to bash scripts in the `rootfs/` folder. - The recommended mount point to persist data changes to `/bitnami/redis/data`. -- The main `redis.conf` file is not persisted in a volume. The path is `/opt/bitnami/redis/etc/redis.conf`. +- The main `redis.conf` file is not persisted in a volume. The path is `/opt/bitnami/redis/mounted-etc/redis.conf`. - Backwards compatibility is not guaranteed when data is persisted using docker-compose. You can use the workaround below to overcome it: ```bash