From a706f58d1eda013be586ae02817fe416aa92d6ec Mon Sep 17 00:00:00 2001 From: Laurent Goderre Date: Thu, 6 Feb 2025 14:05:28 -0500 Subject: [PATCH] Add support for config fragments --- 6.2/alpine/Dockerfile | 19 ++++++++----------- 6.2/alpine/docker-entrypoint.sh | 2 +- 6.2/debian/Dockerfile | 19 ++++++++----------- 6.2/debian/docker-entrypoint.sh | 2 +- 7.0/alpine/Dockerfile | 19 ++++++++----------- 7.0/alpine/docker-entrypoint.sh | 2 +- 7.0/debian/Dockerfile | 19 ++++++++----------- 7.0/debian/docker-entrypoint.sh | 2 +- 7.2/alpine/Dockerfile | 19 ++++++++----------- 7.2/alpine/docker-entrypoint.sh | 2 +- 7.2/debian/Dockerfile | 19 ++++++++----------- 7.2/debian/docker-entrypoint.sh | 2 +- 7.4-rc/alpine/Dockerfile | 19 ++++++++----------- 7.4-rc/alpine/docker-entrypoint.sh | 2 +- 7.4-rc/debian/Dockerfile | 19 ++++++++----------- 7.4-rc/debian/docker-entrypoint.sh | 2 +- 7.4/alpine/Dockerfile | 19 ++++++++----------- 7.4/alpine/docker-entrypoint.sh | 2 +- 7.4/debian/Dockerfile | 19 ++++++++----------- 7.4/debian/docker-entrypoint.sh | 2 +- Dockerfile.template | 19 ++++++++----------- docker-entrypoint.sh | 2 +- 22 files changed, 99 insertions(+), 132 deletions(-) diff --git a/6.2/alpine/Dockerfile b/6.2/alpine/Dockerfile index 65ad72e16..b39ed7e4e 100644 --- a/6.2/alpine/Dockerfile +++ b/6.2/alpine/Dockerfile @@ -76,16 +76,6 @@ RUN set -eux; \ tar -xzf redis.tar.gz -C /usr/src/redis --strip-components=1; \ rm redis.tar.gz; \ \ -# disable Redis protected mode [1] as it is unnecessary in context of Docker -# (ports are not automatically exposed when running inside Docker, but rather explicitly by specifying -p / -P) -# [1]: https://github.com/redis/redis/commit/edd4d555df57dc84265fdfb4ef59a4678832f6da - grep -E '^ *createBoolConfig[(]"protected-mode",.*, *1 *,.*[)],$' /usr/src/redis/src/config.c; \ - sed -ri 's!^( *createBoolConfig[(]"protected-mode",.*, *)1( *,.*[)],)$!\10\2!' /usr/src/redis/src/config.c; \ - grep -E '^ *createBoolConfig[(]"protected-mode",.*, *0 *,.*[)],$' /usr/src/redis/src/config.c; \ -# for future reference, we modify this directly in the source instead of just supplying a default configuration flag because apparently "if you specify any argument to redis-server, [it assumes] you are going to specify everything" -# see also https://github.com/docker-library/redis/issues/4#issuecomment-50780840 -# (more exactly, this makes sure the default behavior of "save on SIGTERM" stays functional by default) - \ # https://github.com/jemalloc/jemalloc/issues/467 -- we need to patch the "./configure" for the bundled jemalloc to match how Debian compiles, for compatibility # (also, we do cross-builds, so we need to embed the appropriate "--build=xxx" values to that "./configure" invocation) gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ @@ -128,7 +118,14 @@ RUN set -eux; \ apk del --no-network .build-deps; \ \ redis-cli --version; \ - redis-server --version + redis-server --version; + +RUN set -ex; \ + mkdir -p /usr/local/etc/redis/conf.d/; \ + # Disable Redis protected mode [1] as it is unnecessary in context of Docker + # [1]: https://github.com/redis/redis/commit/edd4d555df57dc84265fdfb4ef59a4678832f6da + # (more exactly, this makes sure the default behavior of "save on SIGTERM" stays functional by default) + echo 'protected-mode no' > /usr/local/etc/redis/conf.d/docker.conf RUN mkdir /data && chown redis:redis /data VOLUME /data diff --git a/6.2/alpine/docker-entrypoint.sh b/6.2/alpine/docker-entrypoint.sh index 30406a513..6f4de2945 100755 --- a/6.2/alpine/docker-entrypoint.sh +++ b/6.2/alpine/docker-entrypoint.sh @@ -4,7 +4,7 @@ set -e # first arg is `-f` or `--some-option` # or first arg is `something.conf` if [ "${1#-}" != "$1" ] || [ "${1%.conf}" != "$1" ]; then - set -- redis-server "$@" + set -- redis-server "$@" '--include=/usr/local/etc/redis/conf.d/*.conf' fi # allow the container to be started with `--user` diff --git a/6.2/debian/Dockerfile b/6.2/debian/Dockerfile index f58171f88..00bfa89d6 100644 --- a/6.2/debian/Dockerfile +++ b/6.2/debian/Dockerfile @@ -82,16 +82,6 @@ RUN set -eux; \ tar -xzf redis.tar.gz -C /usr/src/redis --strip-components=1; \ rm redis.tar.gz; \ \ -# disable Redis protected mode [1] as it is unnecessary in context of Docker -# (ports are not automatically exposed when running inside Docker, but rather explicitly by specifying -p / -P) -# [1]: https://github.com/redis/redis/commit/edd4d555df57dc84265fdfb4ef59a4678832f6da - grep -E '^ *createBoolConfig[(]"protected-mode",.*, *1 *,.*[)],$' /usr/src/redis/src/config.c; \ - sed -ri 's!^( *createBoolConfig[(]"protected-mode",.*, *)1( *,.*[)],)$!\10\2!' /usr/src/redis/src/config.c; \ - grep -E '^ *createBoolConfig[(]"protected-mode",.*, *0 *,.*[)],$' /usr/src/redis/src/config.c; \ -# for future reference, we modify this directly in the source instead of just supplying a default configuration flag because apparently "if you specify any argument to redis-server, [it assumes] you are going to specify everything" -# see also https://github.com/docker-library/redis/issues/4#issuecomment-50780840 -# (more exactly, this makes sure the default behavior of "save on SIGTERM" stays functional by default) - \ # https://github.com/jemalloc/jemalloc/issues/467 -- we need to patch the "./configure" for the bundled jemalloc to match how Debian compiles, for compatibility # (also, we do cross-builds, so we need to embed the appropriate "--build=xxx" values to that "./configure" invocation) gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ @@ -137,7 +127,14 @@ RUN set -eux; \ apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ \ redis-cli --version; \ - redis-server --version + redis-server --version; + +RUN set -ex; \ + mkdir -p /usr/local/etc/redis/conf.d/; \ + # Disable Redis protected mode [1] as it is unnecessary in context of Docker + # [1]: https://github.com/redis/redis/commit/edd4d555df57dc84265fdfb4ef59a4678832f6da + # (more exactly, this makes sure the default behavior of "save on SIGTERM" stays functional by default) + echo 'protected-mode no' > /usr/local/etc/redis/conf.d/docker.conf RUN mkdir /data && chown redis:redis /data VOLUME /data diff --git a/6.2/debian/docker-entrypoint.sh b/6.2/debian/docker-entrypoint.sh index 30406a513..6f4de2945 100755 --- a/6.2/debian/docker-entrypoint.sh +++ b/6.2/debian/docker-entrypoint.sh @@ -4,7 +4,7 @@ set -e # first arg is `-f` or `--some-option` # or first arg is `something.conf` if [ "${1#-}" != "$1" ] || [ "${1%.conf}" != "$1" ]; then - set -- redis-server "$@" + set -- redis-server "$@" '--include=/usr/local/etc/redis/conf.d/*.conf' fi # allow the container to be started with `--user` diff --git a/7.0/alpine/Dockerfile b/7.0/alpine/Dockerfile index 3572db138..1503008cb 100644 --- a/7.0/alpine/Dockerfile +++ b/7.0/alpine/Dockerfile @@ -76,16 +76,6 @@ RUN set -eux; \ tar -xzf redis.tar.gz -C /usr/src/redis --strip-components=1; \ rm redis.tar.gz; \ \ -# disable Redis protected mode [1] as it is unnecessary in context of Docker -# (ports are not automatically exposed when running inside Docker, but rather explicitly by specifying -p / -P) -# [1]: https://github.com/redis/redis/commit/edd4d555df57dc84265fdfb4ef59a4678832f6da - grep -E '^ *createBoolConfig[(]"protected-mode",.*, *1 *,.*[)],$' /usr/src/redis/src/config.c; \ - sed -ri 's!^( *createBoolConfig[(]"protected-mode",.*, *)1( *,.*[)],)$!\10\2!' /usr/src/redis/src/config.c; \ - grep -E '^ *createBoolConfig[(]"protected-mode",.*, *0 *,.*[)],$' /usr/src/redis/src/config.c; \ -# for future reference, we modify this directly in the source instead of just supplying a default configuration flag because apparently "if you specify any argument to redis-server, [it assumes] you are going to specify everything" -# see also https://github.com/docker-library/redis/issues/4#issuecomment-50780840 -# (more exactly, this makes sure the default behavior of "save on SIGTERM" stays functional by default) - \ # https://github.com/jemalloc/jemalloc/issues/467 -- we need to patch the "./configure" for the bundled jemalloc to match how Debian compiles, for compatibility # (also, we do cross-builds, so we need to embed the appropriate "--build=xxx" values to that "./configure" invocation) gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ @@ -128,7 +118,14 @@ RUN set -eux; \ apk del --no-network .build-deps; \ \ redis-cli --version; \ - redis-server --version + redis-server --version; + +RUN set -ex; \ + mkdir -p /usr/local/etc/redis/conf.d/; \ + # Disable Redis protected mode [1] as it is unnecessary in context of Docker + # [1]: https://github.com/redis/redis/commit/edd4d555df57dc84265fdfb4ef59a4678832f6da + # (more exactly, this makes sure the default behavior of "save on SIGTERM" stays functional by default) + echo 'protected-mode no' > /usr/local/etc/redis/conf.d/docker.conf RUN mkdir /data && chown redis:redis /data VOLUME /data diff --git a/7.0/alpine/docker-entrypoint.sh b/7.0/alpine/docker-entrypoint.sh index 30406a513..6f4de2945 100755 --- a/7.0/alpine/docker-entrypoint.sh +++ b/7.0/alpine/docker-entrypoint.sh @@ -4,7 +4,7 @@ set -e # first arg is `-f` or `--some-option` # or first arg is `something.conf` if [ "${1#-}" != "$1" ] || [ "${1%.conf}" != "$1" ]; then - set -- redis-server "$@" + set -- redis-server "$@" '--include=/usr/local/etc/redis/conf.d/*.conf' fi # allow the container to be started with `--user` diff --git a/7.0/debian/Dockerfile b/7.0/debian/Dockerfile index d252fa65c..7e2a7ffdb 100644 --- a/7.0/debian/Dockerfile +++ b/7.0/debian/Dockerfile @@ -82,16 +82,6 @@ RUN set -eux; \ tar -xzf redis.tar.gz -C /usr/src/redis --strip-components=1; \ rm redis.tar.gz; \ \ -# disable Redis protected mode [1] as it is unnecessary in context of Docker -# (ports are not automatically exposed when running inside Docker, but rather explicitly by specifying -p / -P) -# [1]: https://github.com/redis/redis/commit/edd4d555df57dc84265fdfb4ef59a4678832f6da - grep -E '^ *createBoolConfig[(]"protected-mode",.*, *1 *,.*[)],$' /usr/src/redis/src/config.c; \ - sed -ri 's!^( *createBoolConfig[(]"protected-mode",.*, *)1( *,.*[)],)$!\10\2!' /usr/src/redis/src/config.c; \ - grep -E '^ *createBoolConfig[(]"protected-mode",.*, *0 *,.*[)],$' /usr/src/redis/src/config.c; \ -# for future reference, we modify this directly in the source instead of just supplying a default configuration flag because apparently "if you specify any argument to redis-server, [it assumes] you are going to specify everything" -# see also https://github.com/docker-library/redis/issues/4#issuecomment-50780840 -# (more exactly, this makes sure the default behavior of "save on SIGTERM" stays functional by default) - \ # https://github.com/jemalloc/jemalloc/issues/467 -- we need to patch the "./configure" for the bundled jemalloc to match how Debian compiles, for compatibility # (also, we do cross-builds, so we need to embed the appropriate "--build=xxx" values to that "./configure" invocation) gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ @@ -137,7 +127,14 @@ RUN set -eux; \ apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ \ redis-cli --version; \ - redis-server --version + redis-server --version; + +RUN set -ex; \ + mkdir -p /usr/local/etc/redis/conf.d/; \ + # Disable Redis protected mode [1] as it is unnecessary in context of Docker + # [1]: https://github.com/redis/redis/commit/edd4d555df57dc84265fdfb4ef59a4678832f6da + # (more exactly, this makes sure the default behavior of "save on SIGTERM" stays functional by default) + echo 'protected-mode no' > /usr/local/etc/redis/conf.d/docker.conf RUN mkdir /data && chown redis:redis /data VOLUME /data diff --git a/7.0/debian/docker-entrypoint.sh b/7.0/debian/docker-entrypoint.sh index 30406a513..6f4de2945 100755 --- a/7.0/debian/docker-entrypoint.sh +++ b/7.0/debian/docker-entrypoint.sh @@ -4,7 +4,7 @@ set -e # first arg is `-f` or `--some-option` # or first arg is `something.conf` if [ "${1#-}" != "$1" ] || [ "${1%.conf}" != "$1" ]; then - set -- redis-server "$@" + set -- redis-server "$@" '--include=/usr/local/etc/redis/conf.d/*.conf' fi # allow the container to be started with `--user` diff --git a/7.2/alpine/Dockerfile b/7.2/alpine/Dockerfile index ce7245749..ad7e0826c 100644 --- a/7.2/alpine/Dockerfile +++ b/7.2/alpine/Dockerfile @@ -76,16 +76,6 @@ RUN set -eux; \ tar -xzf redis.tar.gz -C /usr/src/redis --strip-components=1; \ rm redis.tar.gz; \ \ -# disable Redis protected mode [1] as it is unnecessary in context of Docker -# (ports are not automatically exposed when running inside Docker, but rather explicitly by specifying -p / -P) -# [1]: https://github.com/redis/redis/commit/edd4d555df57dc84265fdfb4ef59a4678832f6da - grep -E '^ *createBoolConfig[(]"protected-mode",.*, *1 *,.*[)],$' /usr/src/redis/src/config.c; \ - sed -ri 's!^( *createBoolConfig[(]"protected-mode",.*, *)1( *,.*[)],)$!\10\2!' /usr/src/redis/src/config.c; \ - grep -E '^ *createBoolConfig[(]"protected-mode",.*, *0 *,.*[)],$' /usr/src/redis/src/config.c; \ -# for future reference, we modify this directly in the source instead of just supplying a default configuration flag because apparently "if you specify any argument to redis-server, [it assumes] you are going to specify everything" -# see also https://github.com/docker-library/redis/issues/4#issuecomment-50780840 -# (more exactly, this makes sure the default behavior of "save on SIGTERM" stays functional by default) - \ # https://github.com/jemalloc/jemalloc/issues/467 -- we need to patch the "./configure" for the bundled jemalloc to match how Debian compiles, for compatibility # (also, we do cross-builds, so we need to embed the appropriate "--build=xxx" values to that "./configure" invocation) gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ @@ -128,7 +118,14 @@ RUN set -eux; \ apk del --no-network .build-deps; \ \ redis-cli --version; \ - redis-server --version + redis-server --version; + +RUN set -ex; \ + mkdir -p /usr/local/etc/redis/conf.d/; \ + # Disable Redis protected mode [1] as it is unnecessary in context of Docker + # [1]: https://github.com/redis/redis/commit/edd4d555df57dc84265fdfb4ef59a4678832f6da + # (more exactly, this makes sure the default behavior of "save on SIGTERM" stays functional by default) + echo 'protected-mode no' > /usr/local/etc/redis/conf.d/docker.conf RUN mkdir /data && chown redis:redis /data VOLUME /data diff --git a/7.2/alpine/docker-entrypoint.sh b/7.2/alpine/docker-entrypoint.sh index 30406a513..6f4de2945 100755 --- a/7.2/alpine/docker-entrypoint.sh +++ b/7.2/alpine/docker-entrypoint.sh @@ -4,7 +4,7 @@ set -e # first arg is `-f` or `--some-option` # or first arg is `something.conf` if [ "${1#-}" != "$1" ] || [ "${1%.conf}" != "$1" ]; then - set -- redis-server "$@" + set -- redis-server "$@" '--include=/usr/local/etc/redis/conf.d/*.conf' fi # allow the container to be started with `--user` diff --git a/7.2/debian/Dockerfile b/7.2/debian/Dockerfile index bc175b39f..8976f89b1 100644 --- a/7.2/debian/Dockerfile +++ b/7.2/debian/Dockerfile @@ -82,16 +82,6 @@ RUN set -eux; \ tar -xzf redis.tar.gz -C /usr/src/redis --strip-components=1; \ rm redis.tar.gz; \ \ -# disable Redis protected mode [1] as it is unnecessary in context of Docker -# (ports are not automatically exposed when running inside Docker, but rather explicitly by specifying -p / -P) -# [1]: https://github.com/redis/redis/commit/edd4d555df57dc84265fdfb4ef59a4678832f6da - grep -E '^ *createBoolConfig[(]"protected-mode",.*, *1 *,.*[)],$' /usr/src/redis/src/config.c; \ - sed -ri 's!^( *createBoolConfig[(]"protected-mode",.*, *)1( *,.*[)],)$!\10\2!' /usr/src/redis/src/config.c; \ - grep -E '^ *createBoolConfig[(]"protected-mode",.*, *0 *,.*[)],$' /usr/src/redis/src/config.c; \ -# for future reference, we modify this directly in the source instead of just supplying a default configuration flag because apparently "if you specify any argument to redis-server, [it assumes] you are going to specify everything" -# see also https://github.com/docker-library/redis/issues/4#issuecomment-50780840 -# (more exactly, this makes sure the default behavior of "save on SIGTERM" stays functional by default) - \ # https://github.com/jemalloc/jemalloc/issues/467 -- we need to patch the "./configure" for the bundled jemalloc to match how Debian compiles, for compatibility # (also, we do cross-builds, so we need to embed the appropriate "--build=xxx" values to that "./configure" invocation) gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ @@ -137,7 +127,14 @@ RUN set -eux; \ apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ \ redis-cli --version; \ - redis-server --version + redis-server --version; + +RUN set -ex; \ + mkdir -p /usr/local/etc/redis/conf.d/; \ + # Disable Redis protected mode [1] as it is unnecessary in context of Docker + # [1]: https://github.com/redis/redis/commit/edd4d555df57dc84265fdfb4ef59a4678832f6da + # (more exactly, this makes sure the default behavior of "save on SIGTERM" stays functional by default) + echo 'protected-mode no' > /usr/local/etc/redis/conf.d/docker.conf RUN mkdir /data && chown redis:redis /data VOLUME /data diff --git a/7.2/debian/docker-entrypoint.sh b/7.2/debian/docker-entrypoint.sh index 30406a513..6f4de2945 100755 --- a/7.2/debian/docker-entrypoint.sh +++ b/7.2/debian/docker-entrypoint.sh @@ -4,7 +4,7 @@ set -e # first arg is `-f` or `--some-option` # or first arg is `something.conf` if [ "${1#-}" != "$1" ] || [ "${1%.conf}" != "$1" ]; then - set -- redis-server "$@" + set -- redis-server "$@" '--include=/usr/local/etc/redis/conf.d/*.conf' fi # allow the container to be started with `--user` diff --git a/7.4-rc/alpine/Dockerfile b/7.4-rc/alpine/Dockerfile index df76586f2..688f24184 100644 --- a/7.4-rc/alpine/Dockerfile +++ b/7.4-rc/alpine/Dockerfile @@ -76,16 +76,6 @@ RUN set -eux; \ tar -xzf redis.tar.gz -C /usr/src/redis --strip-components=1; \ rm redis.tar.gz; \ \ -# disable Redis protected mode [1] as it is unnecessary in context of Docker -# (ports are not automatically exposed when running inside Docker, but rather explicitly by specifying -p / -P) -# [1]: https://github.com/redis/redis/commit/edd4d555df57dc84265fdfb4ef59a4678832f6da - grep -E '^ *createBoolConfig[(]"protected-mode",.*, *1 *,.*[)],$' /usr/src/redis/src/config.c; \ - sed -ri 's!^( *createBoolConfig[(]"protected-mode",.*, *)1( *,.*[)],)$!\10\2!' /usr/src/redis/src/config.c; \ - grep -E '^ *createBoolConfig[(]"protected-mode",.*, *0 *,.*[)],$' /usr/src/redis/src/config.c; \ -# for future reference, we modify this directly in the source instead of just supplying a default configuration flag because apparently "if you specify any argument to redis-server, [it assumes] you are going to specify everything" -# see also https://github.com/docker-library/redis/issues/4#issuecomment-50780840 -# (more exactly, this makes sure the default behavior of "save on SIGTERM" stays functional by default) - \ # https://github.com/jemalloc/jemalloc/issues/467 -- we need to patch the "./configure" for the bundled jemalloc to match how Debian compiles, for compatibility # (also, we do cross-builds, so we need to embed the appropriate "--build=xxx" values to that "./configure" invocation) gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ @@ -128,7 +118,14 @@ RUN set -eux; \ apk del --no-network .build-deps; \ \ redis-cli --version; \ - redis-server --version + redis-server --version; + +RUN set -ex; \ + mkdir -p /usr/local/etc/redis/conf.d/; \ + # Disable Redis protected mode [1] as it is unnecessary in context of Docker + # [1]: https://github.com/redis/redis/commit/edd4d555df57dc84265fdfb4ef59a4678832f6da + # (more exactly, this makes sure the default behavior of "save on SIGTERM" stays functional by default) + echo 'protected-mode no' > /usr/local/etc/redis/conf.d/docker.conf RUN mkdir /data && chown redis:redis /data VOLUME /data diff --git a/7.4-rc/alpine/docker-entrypoint.sh b/7.4-rc/alpine/docker-entrypoint.sh index 30406a513..6f4de2945 100755 --- a/7.4-rc/alpine/docker-entrypoint.sh +++ b/7.4-rc/alpine/docker-entrypoint.sh @@ -4,7 +4,7 @@ set -e # first arg is `-f` or `--some-option` # or first arg is `something.conf` if [ "${1#-}" != "$1" ] || [ "${1%.conf}" != "$1" ]; then - set -- redis-server "$@" + set -- redis-server "$@" '--include=/usr/local/etc/redis/conf.d/*.conf' fi # allow the container to be started with `--user` diff --git a/7.4-rc/debian/Dockerfile b/7.4-rc/debian/Dockerfile index 3f202ef71..ca345fad8 100644 --- a/7.4-rc/debian/Dockerfile +++ b/7.4-rc/debian/Dockerfile @@ -82,16 +82,6 @@ RUN set -eux; \ tar -xzf redis.tar.gz -C /usr/src/redis --strip-components=1; \ rm redis.tar.gz; \ \ -# disable Redis protected mode [1] as it is unnecessary in context of Docker -# (ports are not automatically exposed when running inside Docker, but rather explicitly by specifying -p / -P) -# [1]: https://github.com/redis/redis/commit/edd4d555df57dc84265fdfb4ef59a4678832f6da - grep -E '^ *createBoolConfig[(]"protected-mode",.*, *1 *,.*[)],$' /usr/src/redis/src/config.c; \ - sed -ri 's!^( *createBoolConfig[(]"protected-mode",.*, *)1( *,.*[)],)$!\10\2!' /usr/src/redis/src/config.c; \ - grep -E '^ *createBoolConfig[(]"protected-mode",.*, *0 *,.*[)],$' /usr/src/redis/src/config.c; \ -# for future reference, we modify this directly in the source instead of just supplying a default configuration flag because apparently "if you specify any argument to redis-server, [it assumes] you are going to specify everything" -# see also https://github.com/docker-library/redis/issues/4#issuecomment-50780840 -# (more exactly, this makes sure the default behavior of "save on SIGTERM" stays functional by default) - \ # https://github.com/jemalloc/jemalloc/issues/467 -- we need to patch the "./configure" for the bundled jemalloc to match how Debian compiles, for compatibility # (also, we do cross-builds, so we need to embed the appropriate "--build=xxx" values to that "./configure" invocation) gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ @@ -137,7 +127,14 @@ RUN set -eux; \ apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ \ redis-cli --version; \ - redis-server --version + redis-server --version; + +RUN set -ex; \ + mkdir -p /usr/local/etc/redis/conf.d/; \ + # Disable Redis protected mode [1] as it is unnecessary in context of Docker + # [1]: https://github.com/redis/redis/commit/edd4d555df57dc84265fdfb4ef59a4678832f6da + # (more exactly, this makes sure the default behavior of "save on SIGTERM" stays functional by default) + echo 'protected-mode no' > /usr/local/etc/redis/conf.d/docker.conf RUN mkdir /data && chown redis:redis /data VOLUME /data diff --git a/7.4-rc/debian/docker-entrypoint.sh b/7.4-rc/debian/docker-entrypoint.sh index 30406a513..6f4de2945 100755 --- a/7.4-rc/debian/docker-entrypoint.sh +++ b/7.4-rc/debian/docker-entrypoint.sh @@ -4,7 +4,7 @@ set -e # first arg is `-f` or `--some-option` # or first arg is `something.conf` if [ "${1#-}" != "$1" ] || [ "${1%.conf}" != "$1" ]; then - set -- redis-server "$@" + set -- redis-server "$@" '--include=/usr/local/etc/redis/conf.d/*.conf' fi # allow the container to be started with `--user` diff --git a/7.4/alpine/Dockerfile b/7.4/alpine/Dockerfile index 179e99875..c6f6e8cae 100644 --- a/7.4/alpine/Dockerfile +++ b/7.4/alpine/Dockerfile @@ -76,16 +76,6 @@ RUN set -eux; \ tar -xzf redis.tar.gz -C /usr/src/redis --strip-components=1; \ rm redis.tar.gz; \ \ -# disable Redis protected mode [1] as it is unnecessary in context of Docker -# (ports are not automatically exposed when running inside Docker, but rather explicitly by specifying -p / -P) -# [1]: https://github.com/redis/redis/commit/edd4d555df57dc84265fdfb4ef59a4678832f6da - grep -E '^ *createBoolConfig[(]"protected-mode",.*, *1 *,.*[)],$' /usr/src/redis/src/config.c; \ - sed -ri 's!^( *createBoolConfig[(]"protected-mode",.*, *)1( *,.*[)],)$!\10\2!' /usr/src/redis/src/config.c; \ - grep -E '^ *createBoolConfig[(]"protected-mode",.*, *0 *,.*[)],$' /usr/src/redis/src/config.c; \ -# for future reference, we modify this directly in the source instead of just supplying a default configuration flag because apparently "if you specify any argument to redis-server, [it assumes] you are going to specify everything" -# see also https://github.com/docker-library/redis/issues/4#issuecomment-50780840 -# (more exactly, this makes sure the default behavior of "save on SIGTERM" stays functional by default) - \ # https://github.com/jemalloc/jemalloc/issues/467 -- we need to patch the "./configure" for the bundled jemalloc to match how Debian compiles, for compatibility # (also, we do cross-builds, so we need to embed the appropriate "--build=xxx" values to that "./configure" invocation) gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ @@ -128,7 +118,14 @@ RUN set -eux; \ apk del --no-network .build-deps; \ \ redis-cli --version; \ - redis-server --version + redis-server --version; + +RUN set -ex; \ + mkdir -p /usr/local/etc/redis/conf.d/; \ + # Disable Redis protected mode [1] as it is unnecessary in context of Docker + # [1]: https://github.com/redis/redis/commit/edd4d555df57dc84265fdfb4ef59a4678832f6da + # (more exactly, this makes sure the default behavior of "save on SIGTERM" stays functional by default) + echo 'protected-mode no' > /usr/local/etc/redis/conf.d/docker.conf RUN mkdir /data && chown redis:redis /data VOLUME /data diff --git a/7.4/alpine/docker-entrypoint.sh b/7.4/alpine/docker-entrypoint.sh index 30406a513..6f4de2945 100755 --- a/7.4/alpine/docker-entrypoint.sh +++ b/7.4/alpine/docker-entrypoint.sh @@ -4,7 +4,7 @@ set -e # first arg is `-f` or `--some-option` # or first arg is `something.conf` if [ "${1#-}" != "$1" ] || [ "${1%.conf}" != "$1" ]; then - set -- redis-server "$@" + set -- redis-server "$@" '--include=/usr/local/etc/redis/conf.d/*.conf' fi # allow the container to be started with `--user` diff --git a/7.4/debian/Dockerfile b/7.4/debian/Dockerfile index 79c700232..5ca406a08 100644 --- a/7.4/debian/Dockerfile +++ b/7.4/debian/Dockerfile @@ -82,16 +82,6 @@ RUN set -eux; \ tar -xzf redis.tar.gz -C /usr/src/redis --strip-components=1; \ rm redis.tar.gz; \ \ -# disable Redis protected mode [1] as it is unnecessary in context of Docker -# (ports are not automatically exposed when running inside Docker, but rather explicitly by specifying -p / -P) -# [1]: https://github.com/redis/redis/commit/edd4d555df57dc84265fdfb4ef59a4678832f6da - grep -E '^ *createBoolConfig[(]"protected-mode",.*, *1 *,.*[)],$' /usr/src/redis/src/config.c; \ - sed -ri 's!^( *createBoolConfig[(]"protected-mode",.*, *)1( *,.*[)],)$!\10\2!' /usr/src/redis/src/config.c; \ - grep -E '^ *createBoolConfig[(]"protected-mode",.*, *0 *,.*[)],$' /usr/src/redis/src/config.c; \ -# for future reference, we modify this directly in the source instead of just supplying a default configuration flag because apparently "if you specify any argument to redis-server, [it assumes] you are going to specify everything" -# see also https://github.com/docker-library/redis/issues/4#issuecomment-50780840 -# (more exactly, this makes sure the default behavior of "save on SIGTERM" stays functional by default) - \ # https://github.com/jemalloc/jemalloc/issues/467 -- we need to patch the "./configure" for the bundled jemalloc to match how Debian compiles, for compatibility # (also, we do cross-builds, so we need to embed the appropriate "--build=xxx" values to that "./configure" invocation) gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ @@ -137,7 +127,14 @@ RUN set -eux; \ apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ \ redis-cli --version; \ - redis-server --version + redis-server --version; + +RUN set -ex; \ + mkdir -p /usr/local/etc/redis/conf.d/; \ + # Disable Redis protected mode [1] as it is unnecessary in context of Docker + # [1]: https://github.com/redis/redis/commit/edd4d555df57dc84265fdfb4ef59a4678832f6da + # (more exactly, this makes sure the default behavior of "save on SIGTERM" stays functional by default) + echo 'protected-mode no' > /usr/local/etc/redis/conf.d/docker.conf RUN mkdir /data && chown redis:redis /data VOLUME /data diff --git a/7.4/debian/docker-entrypoint.sh b/7.4/debian/docker-entrypoint.sh index 30406a513..6f4de2945 100755 --- a/7.4/debian/docker-entrypoint.sh +++ b/7.4/debian/docker-entrypoint.sh @@ -4,7 +4,7 @@ set -e # first arg is `-f` or `--some-option` # or first arg is `something.conf` if [ "${1#-}" != "$1" ] || [ "${1%.conf}" != "$1" ]; then - set -- redis-server "$@" + set -- redis-server "$@" '--include=/usr/local/etc/redis/conf.d/*.conf' fi # allow the container to be started with `--user` diff --git a/Dockerfile.template b/Dockerfile.template index 489f6102a..aec9dd035 100644 --- a/Dockerfile.template +++ b/Dockerfile.template @@ -158,16 +158,6 @@ RUN set -eux; \ tar -xzf redis.tar.gz -C /usr/src/redis --strip-components=1; \ rm redis.tar.gz; \ \ -# disable Redis protected mode [1] as it is unnecessary in context of Docker -# (ports are not automatically exposed when running inside Docker, but rather explicitly by specifying -p / -P) -# [1]: https://github.com/redis/redis/commit/edd4d555df57dc84265fdfb4ef59a4678832f6da - grep -E '^ *createBoolConfig[(]"protected-mode",.*, *1 *,.*[)],$' /usr/src/redis/src/config.c; \ - sed -ri 's!^( *createBoolConfig[(]"protected-mode",.*, *)1( *,.*[)],)$!\10\2!' /usr/src/redis/src/config.c; \ - grep -E '^ *createBoolConfig[(]"protected-mode",.*, *0 *,.*[)],$' /usr/src/redis/src/config.c; \ -# for future reference, we modify this directly in the source instead of just supplying a default configuration flag because apparently "if you specify any argument to redis-server, [it assumes] you are going to specify everything" -# see also https://github.com/docker-library/redis/issues/4#issuecomment-50780840 -# (more exactly, this makes sure the default behavior of "save on SIGTERM" stays functional by default) - \ # https://github.com/jemalloc/jemalloc/issues/467 -- we need to patch the "./configure" for the bundled jemalloc to match how Debian compiles, for compatibility # (also, we do cross-builds, so we need to embed the appropriate "--build=xxx" values to that "./configure" invocation) gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ @@ -224,7 +214,14 @@ RUN set -eux; \ {{ ) end -}} \ redis-cli --version; \ - redis-server --version + redis-server --version; + +RUN set -ex; \ + mkdir -p /usr/local/etc/redis/conf.d/; \ + # Disable Redis protected mode [1] as it is unnecessary in context of Docker + # [1]: https://github.com/redis/redis/commit/edd4d555df57dc84265fdfb4ef59a4678832f6da + # (more exactly, this makes sure the default behavior of "save on SIGTERM" stays functional by default) + echo 'protected-mode no' > /usr/local/etc/redis/conf.d/docker.conf RUN mkdir /data && chown redis:redis /data VOLUME /data diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 30406a513..6f4de2945 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -4,7 +4,7 @@ set -e # first arg is `-f` or `--some-option` # or first arg is `something.conf` if [ "${1#-}" != "$1" ] || [ "${1%.conf}" != "$1" ]; then - set -- redis-server "$@" + set -- redis-server "$@" '--include=/usr/local/etc/redis/conf.d/*.conf' fi # allow the container to be started with `--user`