Skip to content

Commit fb3e83e

Browse files
committed
Add 7.2-rc1
1 parent e331696 commit fb3e83e

File tree

4 files changed

+270
-0
lines changed

4 files changed

+270
-0
lines changed

7.2-rc/Dockerfile

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
FROM debian:bullseye-slim
2+
3+
# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
4+
RUN groupadd -r -g 999 redis && useradd -r -g redis -u 999 redis
5+
6+
# grab gosu for easy step-down from root
7+
# https://github.com/tianon/gosu/releases
8+
ENV GOSU_VERSION 1.16
9+
RUN set -eux; \
10+
savedAptMark="$(apt-mark showmanual)"; \
11+
apt-get update; \
12+
apt-get install -y --no-install-recommends ca-certificates dirmngr gnupg wget; \
13+
rm -rf /var/lib/apt/lists/*; \
14+
dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')"; \
15+
wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch"; \
16+
wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc"; \
17+
export GNUPGHOME="$(mktemp -d)"; \
18+
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \
19+
gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \
20+
gpgconf --kill all; \
21+
rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc; \
22+
apt-mark auto '.*' > /dev/null; \
23+
[ -z "$savedAptMark" ] || apt-mark manual $savedAptMark > /dev/null; \
24+
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
25+
chmod +x /usr/local/bin/gosu; \
26+
gosu --version; \
27+
gosu nobody true
28+
29+
ENV REDIS_VERSION 7.2-rc1
30+
ENV REDIS_DOWNLOAD_URL https://github.com/redis/redis/archive/7.2-rc1.tar.gz
31+
ENV REDIS_DOWNLOAD_SHA d94d95c448eeb3dca8b4fd4801f9d2f8bdae0f5f84b2d9f5cfbd48cd6d8d5b43
32+
33+
RUN set -eux; \
34+
\
35+
savedAptMark="$(apt-mark showmanual)"; \
36+
apt-get update; \
37+
apt-get install -y --no-install-recommends \
38+
ca-certificates \
39+
wget \
40+
\
41+
dpkg-dev \
42+
gcc \
43+
libc6-dev \
44+
libssl-dev \
45+
make \
46+
; \
47+
rm -rf /var/lib/apt/lists/*; \
48+
\
49+
wget -O redis.tar.gz "$REDIS_DOWNLOAD_URL"; \
50+
echo "$REDIS_DOWNLOAD_SHA *redis.tar.gz" | sha256sum -c -; \
51+
mkdir -p /usr/src/redis; \
52+
tar -xzf redis.tar.gz -C /usr/src/redis --strip-components=1; \
53+
rm redis.tar.gz; \
54+
\
55+
# disable Redis protected mode [1] as it is unnecessary in context of Docker
56+
# (ports are not automatically exposed when running inside Docker, but rather explicitly by specifying -p / -P)
57+
# [1]: https://github.com/redis/redis/commit/edd4d555df57dc84265fdfb4ef59a4678832f6da
58+
grep -E '^ *createBoolConfig[(]"protected-mode",.*, *1 *,.*[)],$' /usr/src/redis/src/config.c; \
59+
sed -ri 's!^( *createBoolConfig[(]"protected-mode",.*, *)1( *,.*[)],)$!\10\2!' /usr/src/redis/src/config.c; \
60+
grep -E '^ *createBoolConfig[(]"protected-mode",.*, *0 *,.*[)],$' /usr/src/redis/src/config.c; \
61+
# 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"
62+
# see also https://github.com/docker-library/redis/issues/4#issuecomment-50780840
63+
# (more exactly, this makes sure the default behavior of "save on SIGTERM" stays functional by default)
64+
\
65+
# https://github.com/jemalloc/jemalloc/issues/467 -- we need to patch the "./configure" for the bundled jemalloc to match how Debian compiles, for compatibility
66+
# (also, we do cross-builds, so we need to embed the appropriate "--build=xxx" values to that "./configure" invocation)
67+
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \
68+
extraJemallocConfigureFlags="--build=$gnuArch"; \
69+
# https://salsa.debian.org/debian/jemalloc/-/blob/c0a88c37a551be7d12e4863435365c9a6a51525f/debian/rules#L8-23
70+
dpkgArch="$(dpkg --print-architecture)"; \
71+
case "${dpkgArch##*-}" in \
72+
amd64 | i386 | x32) extraJemallocConfigureFlags="$extraJemallocConfigureFlags --with-lg-page=12" ;; \
73+
*) extraJemallocConfigureFlags="$extraJemallocConfigureFlags --with-lg-page=16" ;; \
74+
esac; \
75+
extraJemallocConfigureFlags="$extraJemallocConfigureFlags --with-lg-hugepage=21"; \
76+
grep -F 'cd jemalloc && ./configure ' /usr/src/redis/deps/Makefile; \
77+
sed -ri 's!cd jemalloc && ./configure !&'"$extraJemallocConfigureFlags"' !' /usr/src/redis/deps/Makefile; \
78+
grep -F "cd jemalloc && ./configure $extraJemallocConfigureFlags " /usr/src/redis/deps/Makefile; \
79+
\
80+
export BUILD_TLS=yes; \
81+
make -C /usr/src/redis -j "$(nproc)" all; \
82+
make -C /usr/src/redis install; \
83+
\
84+
# TODO https://github.com/redis/redis/pull/3494 (deduplicate "redis-server" copies)
85+
serverMd5="$(md5sum /usr/local/bin/redis-server | cut -d' ' -f1)"; export serverMd5; \
86+
find /usr/local/bin/redis* -maxdepth 0 \
87+
-type f -not -name redis-server \
88+
-exec sh -eux -c ' \
89+
md5="$(md5sum "$1" | cut -d" " -f1)"; \
90+
test "$md5" = "$serverMd5"; \
91+
' -- '{}' ';' \
92+
-exec ln -svfT 'redis-server' '{}' ';' \
93+
; \
94+
\
95+
rm -r /usr/src/redis; \
96+
\
97+
apt-mark auto '.*' > /dev/null; \
98+
[ -z "$savedAptMark" ] || apt-mark manual $savedAptMark > /dev/null; \
99+
find /usr/local -type f -executable -exec ldd '{}' ';' \
100+
| awk '/=>/ { print $(NF-1) }' \
101+
| sort -u \
102+
| xargs -r dpkg-query --search \
103+
| cut -d: -f1 \
104+
| sort -u \
105+
| xargs -r apt-mark manual \
106+
; \
107+
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
108+
\
109+
redis-cli --version; \
110+
redis-server --version
111+
112+
RUN mkdir /data && chown redis:redis /data
113+
VOLUME /data
114+
WORKDIR /data
115+
116+
COPY docker-entrypoint.sh /usr/local/bin/
117+
ENTRYPOINT ["docker-entrypoint.sh"]
118+
119+
EXPOSE 6379
120+
CMD ["redis-server"]

7.2-rc/alpine/Dockerfile

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
FROM alpine:3.17
2+
3+
# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
4+
RUN addgroup -S -g 1000 redis && adduser -S -G redis -u 999 redis
5+
# alpine already has a gid 999, so we'll use the next id
6+
7+
RUN apk add --no-cache \
8+
# grab su-exec for easy step-down from root
9+
'su-exec>=0.2' \
10+
# add tzdata for https://github.com/docker-library/redis/issues/138
11+
tzdata
12+
13+
ENV REDIS_VERSION 7.2-rc1
14+
ENV REDIS_DOWNLOAD_URL https://github.com/redis/redis/archive/7.2-rc1.tar.gz
15+
ENV REDIS_DOWNLOAD_SHA d94d95c448eeb3dca8b4fd4801f9d2f8bdae0f5f84b2d9f5cfbd48cd6d8d5b43
16+
17+
RUN set -eux; \
18+
\
19+
apk add --no-cache --virtual .build-deps \
20+
coreutils \
21+
dpkg-dev dpkg \
22+
gcc \
23+
linux-headers \
24+
make \
25+
musl-dev \
26+
openssl-dev \
27+
# install real "wget" to avoid:
28+
# + wget -O redis.tar.gz https://download.redis.io/releases/redis-6.0.6.tar.gz
29+
# Connecting to download.redis.io (45.60.121.1:80)
30+
# wget: bad header line: XxhODalH: btu; path=/; Max-Age=900
31+
wget \
32+
; \
33+
\
34+
wget -O redis.tar.gz "$REDIS_DOWNLOAD_URL"; \
35+
echo "$REDIS_DOWNLOAD_SHA *redis.tar.gz" | sha256sum -c -; \
36+
mkdir -p /usr/src/redis; \
37+
tar -xzf redis.tar.gz -C /usr/src/redis --strip-components=1; \
38+
rm redis.tar.gz; \
39+
\
40+
# disable Redis protected mode [1] as it is unnecessary in context of Docker
41+
# (ports are not automatically exposed when running inside Docker, but rather explicitly by specifying -p / -P)
42+
# [1]: https://github.com/redis/redis/commit/edd4d555df57dc84265fdfb4ef59a4678832f6da
43+
grep -E '^ *createBoolConfig[(]"protected-mode",.*, *1 *,.*[)],$' /usr/src/redis/src/config.c; \
44+
sed -ri 's!^( *createBoolConfig[(]"protected-mode",.*, *)1( *,.*[)],)$!\10\2!' /usr/src/redis/src/config.c; \
45+
grep -E '^ *createBoolConfig[(]"protected-mode",.*, *0 *,.*[)],$' /usr/src/redis/src/config.c; \
46+
# 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"
47+
# see also https://github.com/docker-library/redis/issues/4#issuecomment-50780840
48+
# (more exactly, this makes sure the default behavior of "save on SIGTERM" stays functional by default)
49+
\
50+
# https://github.com/jemalloc/jemalloc/issues/467 -- we need to patch the "./configure" for the bundled jemalloc to match how Debian compiles, for compatibility
51+
# (also, we do cross-builds, so we need to embed the appropriate "--build=xxx" values to that "./configure" invocation)
52+
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \
53+
extraJemallocConfigureFlags="--build=$gnuArch"; \
54+
# https://salsa.debian.org/debian/jemalloc/-/blob/c0a88c37a551be7d12e4863435365c9a6a51525f/debian/rules#L8-23
55+
dpkgArch="$(dpkg --print-architecture)"; \
56+
case "${dpkgArch##*-}" in \
57+
amd64 | i386 | x32) extraJemallocConfigureFlags="$extraJemallocConfigureFlags --with-lg-page=12" ;; \
58+
*) extraJemallocConfigureFlags="$extraJemallocConfigureFlags --with-lg-page=16" ;; \
59+
esac; \
60+
extraJemallocConfigureFlags="$extraJemallocConfigureFlags --with-lg-hugepage=21"; \
61+
grep -F 'cd jemalloc && ./configure ' /usr/src/redis/deps/Makefile; \
62+
sed -ri 's!cd jemalloc && ./configure !&'"$extraJemallocConfigureFlags"' !' /usr/src/redis/deps/Makefile; \
63+
grep -F "cd jemalloc && ./configure $extraJemallocConfigureFlags " /usr/src/redis/deps/Makefile; \
64+
\
65+
export BUILD_TLS=yes; \
66+
make -C /usr/src/redis -j "$(nproc)" all; \
67+
make -C /usr/src/redis install; \
68+
\
69+
# TODO https://github.com/redis/redis/pull/3494 (deduplicate "redis-server" copies)
70+
serverMd5="$(md5sum /usr/local/bin/redis-server | cut -d' ' -f1)"; export serverMd5; \
71+
find /usr/local/bin/redis* -maxdepth 0 \
72+
-type f -not -name redis-server \
73+
-exec sh -eux -c ' \
74+
md5="$(md5sum "$1" | cut -d" " -f1)"; \
75+
test "$md5" = "$serverMd5"; \
76+
' -- '{}' ';' \
77+
-exec ln -svfT 'redis-server' '{}' ';' \
78+
; \
79+
\
80+
rm -r /usr/src/redis; \
81+
\
82+
runDeps="$( \
83+
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local \
84+
| tr ',' '\n' \
85+
| sort -u \
86+
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
87+
)"; \
88+
apk add --no-network --virtual .redis-rundeps $runDeps; \
89+
apk del --no-network .build-deps; \
90+
\
91+
redis-cli --version; \
92+
redis-server --version
93+
94+
RUN mkdir /data && chown redis:redis /data
95+
VOLUME /data
96+
WORKDIR /data
97+
98+
COPY docker-entrypoint.sh /usr/local/bin/
99+
ENTRYPOINT ["docker-entrypoint.sh"]
100+
101+
EXPOSE 6379
102+
CMD ["redis-server"]

7.2-rc/alpine/docker-entrypoint.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/sh
2+
set -e
3+
4+
# first arg is `-f` or `--some-option`
5+
# or first arg is `something.conf`
6+
if [ "${1#-}" != "$1" ] || [ "${1%.conf}" != "$1" ]; then
7+
set -- redis-server "$@"
8+
fi
9+
10+
# allow the container to be started with `--user`
11+
if [ "$1" = 'redis-server' -a "$(id -u)" = '0' ]; then
12+
find . \! -user redis -exec chown redis '{}' +
13+
exec su-exec redis "$0" "$@"
14+
fi
15+
16+
# set an appropriate umask (if one isn't set already)
17+
# - https://github.com/docker-library/redis/issues/305
18+
# - https://github.com/redis/redis/blob/bb875603fb7ff3f9d19aad906bd45d7db98d9a39/utils/systemd-redis_server.service#L37
19+
um="$(umask)"
20+
if [ "$um" = '0022' ]; then
21+
umask 0077
22+
fi
23+
24+
exec "$@"

7.2-rc/docker-entrypoint.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/sh
2+
set -e
3+
4+
# first arg is `-f` or `--some-option`
5+
# or first arg is `something.conf`
6+
if [ "${1#-}" != "$1" ] || [ "${1%.conf}" != "$1" ]; then
7+
set -- redis-server "$@"
8+
fi
9+
10+
# allow the container to be started with `--user`
11+
if [ "$1" = 'redis-server' -a "$(id -u)" = '0' ]; then
12+
find . \! -user redis -exec chown redis '{}' +
13+
exec gosu redis "$0" "$@"
14+
fi
15+
16+
# set an appropriate umask (if one isn't set already)
17+
# - https://github.com/docker-library/redis/issues/305
18+
# - https://github.com/redis/redis/blob/bb875603fb7ff3f9d19aad906bd45d7db98d9a39/utils/systemd-redis_server.service#L37
19+
um="$(umask)"
20+
if [ "$um" = '0022' ]; then
21+
umask 0077
22+
fi
23+
24+
exec "$@"

0 commit comments

Comments
 (0)