redis 6.0.1 official docker Dockerfile modify for detai.com network slow issue

FROM debian:buster-slim

add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added

RUN groupadd -r -g 999 redis && useradd -r -g redis -u 999 redis

grab gosu for easy step-down from root

https://github.com/tianon/gosu/releases

ENV GOSU_VERSION 1.12

COPY source.list /etc/apt/sources.list
COPY gosu /usr/local/bin/gosu
COPY gosu.asc /usr/local/bin/gosu.asc
COPY redis.tar.gz /redis.tar.gz

RUN set -eux;
savedAptMark="KaTeX parse error: Undefined control sequence: \ at position 25: … showmanual)"; \̲ ̲ apt-get update…(dpkg --print-architecture | awk -F- '{ print KaTeX parse error: Expected 'EOF', got '}' at position 4: NF }̲')"; \ # wget …GOSU_VERSION/gosu-KaTeX parse error: Undefined control sequence: \ at position 12: dpkgArch"; \̲ ̲ # wget -O /usr…GOSU_VERSION/gosu-KaTeX parse error: Undefined control sequence: \ at position 16: dpkgArch.asc"; \̲ ̲ export GNUPGHO…(mktemp -d)";
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4;
gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu;
gpgconf --kill all;
rm -rf “KaTeX parse error: Undefined control sequence: \ at position 37: …/bin/gosu.asc; \̲ ̲ apt-mark auto …savedAptMark” ] || apt-mark manual $savedAptMark > /dev/null;
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false;
chmod +x /usr/local/bin/gosu;
gosu --version;
gosu nobody true

ENV REDIS_VERSION 6.0.1
ENV REDIS_DOWNLOAD_URL http://download.redis.io/releases/redis-6.0.1.tar.gz
ENV REDIS_DOWNLOAD_SHA b8756e430479edc162ba9c44dc89ac394316cd482f2dc6b91bcd5fe12593f273

RUN set -eux;

savedAptMark=“KaTeX parse error: Undefined control sequence: \ at position 25: … showmanual)"; \̲ ̲ apt-get update…REDIS_DOWNLOAD_URL”;
echo “$REDIS_DOWNLOAD_SHA *redis.tar.gz” | sha256sum -c -;
mkdir -p /usr/src/redis;
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/antirez/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)

\
export BUILD_TLS=yes; \
make -C /usr/src/redis -j "$(nproc)" all; \
make -C /usr/src/redis install; \
\

TODO https://github.com/antirez/redis/pull/3494 (deduplicate “redis-server” copies)

serverMd5="$(md5sum /usr/local/bin/redis-server | cut -d' ' -f1)"; export serverMd5; \
find /usr/local/bin/redis* -maxdepth 0 \
	-type f -not -name redis-server \
	-exec sh -eux -c ' \
		md5="$(md5sum "$1" | cut -d" " -f1)"; \
		test "$md5" = "$serverMd5"; \
	' -- '{}' ';' \
	-exec ln -svfT 'redis-server' '{}' ';' \
; \
\
rm -r /usr/src/redis; \
\
apt-mark auto '.*' > /dev/null; \
[ -z "$savedAptMark" ] || apt-mark manual $savedAptMark > /dev/null; \
find /usr/local -type f -executable -exec ldd '{}' ';' \
	| awk '/=>/ { print $(NF-1) }' \
	| sort -u \
	| xargs -r dpkg-query --search \
	| cut -d: -f1 \
	| sort -u \
	| xargs -r apt-mark manual \
; \
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
\
redis-cli --version; \
redis-server --version

RUN mkdir /data && chown redis:redis /data
VOLUME /data
WORKDIR /data

COPY docker-entrypoint.sh /usr/local/bin/
ENTRYPOINT [“docker-entrypoint.sh”]

EXPOSE 6379
CMD [“redis-server”]

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值