Skip to content

Commit

Permalink
add redis 5.0.14
Browse files Browse the repository at this point in the history
Signed-off-by: yzewei <[email protected]>
  • Loading branch information
yzewei committed May 21, 2024
1 parent 6d316be commit 8e0faa4
Show file tree
Hide file tree
Showing 4 changed files with 185 additions and 4 deletions.
22 changes: 22 additions & 0 deletions library/redis/5.0.14/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This file is generated by the template.

REGISTRY?=lcr.loongnix.cn
ORGANIZATION?=library
REPOSITORY?=redis
TAG?=5.0.14
VERSION?=5.0.14

IMAGE=$(REGISTRY)/$(ORGANIZATION)/$(REPOSITORY):$(TAG)

default: image

image:
docker build \
--build-arg https_proxy=$(https_proxy) \
-t $(IMAGE) \
-t $(IMAGE)-sid \
./debian

push:
docker push $(IMAGE)
docker push $(IMAGE)-sid
135 changes: 135 additions & 0 deletions library/redis/5.0.14/debian/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
FROM lcr.loongnix.cn/library/debian:sid

# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
RUN set -eux; \
groupadd -r -g 999 redis; \
useradd -r -g redis -u 999 redis

# runtime dependencies
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
# add tzdata explicitly for https://github.com/docker-library/redis/issues/138 (see also https://bugs.debian.org/837060 and related)
tzdata \
; \
rm -rf /var/lib/apt/lists/*

# grab gosu for easy step-down from root
# https://github.com/tianon/gosu/releases
ENV GOSU_VERSION 1.17
#ADD gosu /usr/local/bin/gosu
RUN set -eux; \
savedAptMark="$(apt-mark showmanual)"; \
apt-get update; \
apt-get install -y --no-install-recommends ca-certificates gnupg wget; \
rm -rf /var/lib/apt/lists/*; \
dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')"; \
case "$dpkgArch" in \
#loongarch64) GOSU_REPO="http://cloud.loongnix.cn/releases/loongarch64/tianon/gosu/1.17/gosu-loongarch64";; \
loongarch64) GOSU_REPO="http://cloud.loongnix.cn/releases/loongarch64/tianon/gosu/1.14/gosu-1.14_Linux_loong64.tar.gz";; \
*) GOSU_REPO="https://github.com/tianon/gosu";; \
esac; \
# wget -O /usr/local/bin/gosu "${GOSU_REPO}/releases/download/$GOSU_VERSION/gosu-$dpkgArch"; \
wget -O gosu.tar.gz http://cloud.loongnix.cn/releases/loongarch64/tianon/gosu/1.14/gosu-1.14_Linux_loong64.tar.gz && tar xf gosu.tar.gz && cp gosu-loong64 /usr/local/bin/gosu && rm gosu.tar.gz; \
apt-mark auto '.*' > /dev/null; \
[ -z "$savedAptMark" ] || apt-mark manual $savedAptMark > /dev/null; \
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false;

RUN chmod +x /usr/local/bin/gosu; \
gosu nobody true;

ENV REDIS_VERSION 5.0.14
ENV REDIS_DOWNLOAD_URL http://download.redis.io/releases/redis-5.0.14.tar.gz

RUN set -eux; \
\
savedAptMark="$(apt-mark showmanual)"; \
apt-get update; \
apt-get install -y --no-install-recommends \
ca-certificates \
wget \
\
dpkg-dev \
gcc \
libc6-dev \
libssl-dev \
make \
; \
rm -rf /var/lib/apt/lists/*; \
\
wget -O redis.tar.gz "$REDIS_DOWNLOAD_URL"; \
mkdir -p /usr/src/redis; \
tar -xzf redis.tar.gz -C /usr/src/redis --strip-components=1; \
rm -f /usr/src/redis/deps/jemalloc/build-aux/config.guess /usr/src/redis/deps/jemalloc/build-aux/config.sub; \
wget -O /usr/src/redis/deps/jemalloc/build-aux/config.sub "git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD"; \
wget -O /usr/src/redis/deps/jemalloc/build-aux/config.guess "git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD"; \
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
RUN 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)"; \
extraJemallocConfigureFlags="--build=$gnuArch"; \
# https://salsa.debian.org/debian/jemalloc/-/blob/c0a88c37a551be7d12e4863435365c9a6a51525f/debian/rules#L8-23
dpkgArch="$(dpkg --print-architecture)"; \
case "${dpkgArch##*-}" in \
amd64 | i386 | x32) extraJemallocConfigureFlags="$extraJemallocConfigureFlags --with-lg-page=12" ;; \
*) extraJemallocConfigureFlags="$extraJemallocConfigureFlags --with-lg-page=16" ;; \
esac; \
extraJemallocConfigureFlags="$extraJemallocConfigureFlags --with-lg-hugepage=21"; \
grep -F 'cd jemalloc && ./configure ' /usr/src/redis/deps/Makefile; \
sed -ri 's!cd jemalloc && ./configure !&'"$extraJemallocConfigureFlags"' !' /usr/src/redis/deps/Makefile; \
grep -F "cd jemalloc && ./configure $extraJemallocConfigureFlags " /usr/src/redis/deps/Makefile; \
\
export BUILD_TLS=yes; \
make -C /usr/src/redis -j "$(nproc)" all; \
make -C /usr/src/redis install; \
\
# TODO https://github.com/redis/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 '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); print so }' \
| 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; \
\
echo '{"spdxVersion":"SPDX-2.3","SPDXID":"SPDXRef-DOCUMENT","name":"redis-server-sbom","packages":[{"name":"redis-server","versionInfo":"6.0.20","SPDXID":"SPDXRef-Package--redis-server","externalRefs":[{"referenceCategory":"PACKAGE-MANAGER","referenceType":"purl","referenceLocator":"pkg:generic/[email protected]?os_name=debian&os_version=buster"}],"licenseDeclared":"BSD-3-Clause"}]}' > /usr/local/redis.spdx.json

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"]
24 changes: 24 additions & 0 deletions library/redis/5.0.14/debian/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh
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 "$@"
fi

# allow the container to be started with `--user`
if [ "$1" = 'redis-server' -a "$(id -u)" = '0' ]; then
find . \! -user redis -exec chown redis '{}' +
exec gosu redis "$0" "$@"
fi

# set an appropriate umask (if one isn't set already)
# - https://github.com/docker-library/redis/issues/305
# - https://github.com/redis/redis/blob/bb875603fb7ff3f9d19aad906bd45d7db98d9a39/utils/systemd-redis_server.service#L37
um="$(umask)"
if [ "$um" = '0022' ]; then
umask 0077
fi

exec "$@"
8 changes: 4 additions & 4 deletions portainer/portainer/2.11.1/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ src: clean
wget https://github.com/Loongson-Cloud-Community/portainer/releases/download/2.11.1/portainer-fronted.tar.gz && tar xf portainer-fronted.tar.gz && rm portainer-fronted.tar.gz && \
git clone -b 2.11.1 --depth 1 $(URL) && \
cd $(REPOSITORY) && \
git apply ../$(PATCH) && cd api && go mod vendor
git apply ../$(PATCH) && cd api && go mod tidy && go mod vendor
cd $(REPOSITORY) && bash build/build_binary.sh linux loong64
download: src
mkdir -p dist && cd dist && \
wget -O kubectl http://cloud.loongnix.cn/releases/loongarch64/kubernetes/kubernetes/v1.20.0/kubectl && chmod +x kubectl && \
wget http://cloud.loongnix.cn/releases/loongarch64/docker/cli/24.0.6/cli-loong64-24.0.6.tar.gz && tar xf cli-loong64-24.0.6.tar.gz && cp build/* ./ && rm -rf build cli-loong64-24.0.6.tar.gz && \
wget http://cloud.loongnix.cn/releases/loongarch64/docker/compose/2.22.0/docker-compose-loong64-v2.22.0-rc.1.tar.gz && tar xf docker-compose-loong64-v2.22.0-rc.1.tar.gz && cp docker-compose-loong64-v2.22.0-rc.1/* ./ && rm -rf docker-compose-loong64-v2.22.0-rc.1 docker-compose-loong64-v2.22.0-rc.1.tar.gz && \
http_proxy="" wget -O kubectl http://cloud.loongnix.cn/releases/loongarch64/kubernetes/kubernetes/v1.20.0/kubectl && chmod +x kubectl && \
http_proxy="" wget http://cloud.loongnix.cn/releases/loongarch64/docker/cli/24.0.6/cli-loong64-24.0.6.tar.gz && tar xf cli-loong64-24.0.6.tar.gz && cp build/* ./ && rm -rf build cli-loong64-24.0.6.tar.gz && \
http_proxy="" wget http://cloud.loongnix.cn/releases/loongarch64/docker/compose/2.22.0/docker-compose-loong64-v2.22.0-rc.1.tar.gz && tar xf docker-compose-loong64-v2.22.0-rc.1.tar.gz && cp docker-compose-loong64-v2.22.0-rc.1/* ./ && rm -rf docker-compose-loong64-v2.22.0-rc.1 docker-compose-loong64-v2.22.0-rc.1.tar.gz && \
cp ../portainer/dist/portainer ./
image: download
docker build -t lcr.loongnix.cn/portainer/base:latest -f base.Dockerfile .
Expand Down

0 comments on commit 8e0faa4

Please sign in to comment.