ARG BASE

FROM $BASE as builder

MAINTAINER Opstree Solutions

LABEL VERSION=1.0 \
      ARCH=AMD64 \
      DESCRIPTION="A production grade performance tuned redis docker image created by Opstree Solutions"

ARG REDIS_DOWNLOAD_URL="http://download.redis.io/"

ARG REDIS_VERSION="stable"

RUN apk add --no-cache su-exec tzdata make curl build-base linux-headers bash openssl-dev

RUN curl -fL -Lo /tmp/redis-${REDIS_VERSION}.tar.gz https://dl.wodcloud.com/lyl/redis-stable/ && \
    cd /tmp && \
    tar xvzf redis-${REDIS_VERSION}.tar.gz && \
    cd redis-${REDIS_VERSION} && \
    make && \
    make install BUILD_TLS=yes

FROM $BASE

MAINTAINER Opstree Solutions

LABEL VERSION=1.0 \
      DESCRIPTION="A production grade performance tuned redis docker image created by Opstree Solutions"

COPY --from=builder /usr/local/bin/rcache-server /usr/local/bin/rcache-server
COPY --from=builder /usr/local/bin/rcache-cli /usr/local/bin/rcache-cli

RUN addgroup -S -g 1000 rcache && adduser -S -G  rcache -u 1000  rcache && \
    apk add --no-cache bash

COPY  rcache.conf /etc/rcache/rcache.conf

COPY entrypoint.sh /usr/bin/entrypoint.sh

COPY setupMasterSlave.sh /usr/bin/setupMasterSlave.sh

COPY healthcheck.sh /usr/bin/healthcheck.sh

RUN chown -R  rcache:rcache /etc/rcache

VOLUME ["/data"]

WORKDIR /data

EXPOSE 6379

USER 1000

ENTRYPOINT ["sh","/usr/bin/entrypoint.sh"]
