ARG REPO_LOCATION
# ARG BASE_VERSION=something

FROM ${REPO_LOCATION}minideb AS builder

RUN install_packages curl ca-certificates make gcc pkgconf libc-dev libjemalloc-dev tcl procps

RUN curl -L -o /tmp/redis-stable.tar.gz https://download.redis.io/redis-stable.tar.gz

RUN tar -xf /tmp/redis-stable.tar.gz -C /srv

WORKDIR /srv/redis-stable

RUN make distclean && make -j$(nproc)

###############################################################################

FROM ${REPO_LOCATION}minideb

RUN install_packages libatomic1

COPY --from=builder /srv/redis-stable/src/redis-server /srv/redis-stable/src/redis-cli /srv/redis-stable/src/redis-sentinel /srv/redis-stable/src/redis-check-rdb /srv/redis-stable/src/redis-check-aof /usr/local/bin/
# COPY --from=builder /srv/redis-stable/src/redis-benchmark /usr/local/bin

USER 2100:2100

ENTRYPOINT [ "/usr/local/bin/redis-server" ]