-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
59 lines (51 loc) · 2.04 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
ARG REDIS_VER=7.2.1
#ARG ARCH=arm64v8
#ARG ARCH=x64
ARG OSNICK=bookworm
ARG REDISEARCH_VER=v2.8.4
ARG RUST_VER=1.72.0
ARG REJSON_VER=v2.6.6
# Build RediSearch
FROM debian:bullseye-slim AS redisearch
ARG REDISEARCH_VER
ARG TARGETPLATFORM
RUN apt clean && apt -y update && apt -y install --no-install-recommends \
ca-certificates build-essential g++ make git clang && rm -rf /var/lib/apt/lists/*
WORKDIR /
RUN git clone --recursive --depth 1 --branch ${REDISEARCH_VER} https://github.com/RediSearch/RediSearch.git
WORKDIR /RediSearch
RUN make setup
RUN make build
RUN if [ "$TARGETPLATFORM" = "linux/arm64" ] ; then cp /RediSearch/bin/linux-arm64v8-release/search/redisearch.so /RediSearch/bin/redisearch.so ; elif [ "$TARGETPLATFORM" = "linux/amd64" ] ; then cp /RediSearch/bin/linux-x64-release/search/redisearch.so /RediSearch/bin/redisearch.so ; else echo "unknown build platform" && exit 1 ; fi
# Build RediJSON
FROM rust:${OSNICK} AS rejson
ARG REJSON_VER
RUN apt-get clean && apt-get -y update && apt -y install --no-install-recommends \
clang && rm -rf /var/lib/apt/lists/*
WORKDIR /
RUN git clone --depth 1 --branch ${REJSON_VER} https://github.com/RedisJSON/RedisJSON.git
WORKDIR /RedisJSON
RUN cargo build --release
# Run Redis with RediSearch + RedisJSON
FROM redis:${REDIS_VER}-${OSNICK}
LABEL org.opencontainers.image.description Redis with RediSearch and RedisJSON for arm64 and amd64
ARG REDIS_VER
#ARG ARCH
ARG OSNICK
ARG REDISEARCH_VER
ARG RUST_VER
ARG REJSON_VER
ARG USER=redisuser
# Run as non-root
RUN adduser --disabled-password "$USER" --uid 12345
# Create app directory
WORKDIR /home/$USER
ENV LD_LIBRARY_PATH /usr/lib/redis/modules
WORKDIR /data
COPY --from=redisearch /RediSearch/bin/redisearch.so /usr/lib/redis/modules/
COPY --from=rejson /RedisJSON/target/release/librejson.so /usr/lib/redis/modules/
RUN chown -R "$USER":"$USER" /usr/lib/redis/modules/ && chown -R "$USER":"$USER" /data/
USER 12345
ENTRYPOINT ["redis-server"]
CMD ["--loadmodule", "/usr/lib/redis/modules/redisearch.so", \
"--loadmodule", "/usr/lib/redis/modules/librejson.so"]