1
2
mirror of https://github.com/vimagick/dockerfiles synced 2024-06-16 11:58:47 +00:00
dockerfiles/redis/arm/Dockerfile

66 lines
2.4 KiB
Docker
Raw Normal View History

2018-07-22 11:44:42 +00:00
FROM easypi/alpine-arm:3.8
2016-01-15 23:54:16 +00:00
2018-01-20 19:09:04 +00:00
# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
RUN addgroup -S redis && adduser -S -G redis redis
2016-01-15 23:54:16 +00:00
2018-01-20 19:09:04 +00:00
# grab su-exec for easy step-down from root
2018-07-22 11:44:42 +00:00
RUN apk add --no-cache 'su-exec>=0.2'
2016-01-15 23:54:16 +00:00
2018-07-22 11:44:42 +00:00
ENV REDIS_VERSION 4.0.10
ENV REDIS_DOWNLOAD_URL http://download.redis.io/releases/redis-4.0.10.tar.gz
ENV REDIS_DOWNLOAD_SHA 1db67435a704f8d18aec9b9637b373c34aa233d65b6e174bdac4c1b161f38ca4
2018-01-20 19:09:04 +00:00
# for redis-sentinel see: http://redis.io/topics/sentinel
RUN set -ex; \
\
apk add --no-cache --virtual .build-deps \
coreutils \
gcc \
2018-07-22 11:44:42 +00:00
jemalloc-dev \
2018-01-20 19:09:04 +00:00
linux-headers \
make \
musl-dev \
; \
\
wget -O redis.tar.gz "$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 -q '^#define CONFIG_DEFAULT_PROTECTED_MODE 1$' /usr/src/redis/src/server.h; \
sed -ri 's!^(#define CONFIG_DEFAULT_PROTECTED_MODE) 1$!\1 0!' /usr/src/redis/src/server.h; \
grep -q '^#define CONFIG_DEFAULT_PROTECTED_MODE 0$' /usr/src/redis/src/server.h; \
# 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)
\
make -C /usr/src/redis -j "$(nproc)"; \
make -C /usr/src/redis install; \
\
rm -r /usr/src/redis; \
\
2018-07-22 11:44:42 +00:00
runDeps="$( \
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local \
| tr ',' '\n' \
| sort -u \
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
)"; \
apk add --virtual .redis-rundeps $runDeps; \
apk del .build-deps; \
\
redis-server --version
2018-01-20 19:09:04 +00:00
RUN mkdir /data && chown redis:redis /data
2017-01-19 17:29:07 +00:00
VOLUME /data
2018-01-20 19:09:04 +00:00
WORKDIR /data
2016-01-15 23:54:16 +00:00
2018-01-20 19:09:04 +00:00
COPY docker-entrypoint.sh /usr/local/bin/
ENTRYPOINT ["docker-entrypoint.sh"]
2016-01-15 23:54:16 +00:00
2018-01-20 19:09:04 +00:00
EXPOSE 6379
CMD ["redis-server"]