# Leave empty for x86, set to e.g. "arm64v8/" (note closing slash!) for ARM, e,g, 
# $ docker build --build-arg ARCH="arm64v8/" -t wrk2-arm -f docker/Dockerfile.benchmark-container-prometheus-export .
ARG ARCH=""

FROM ${ARCH}alpine as builder
MAINTAINER Kinvolk

WORKDIR /usr/src
RUN apk add --update alpine-sdk zlib-dev openssl-dev wget lua lua-dev luarocks
RUN luarocks-5.1 install luasocket
COPY ./ /usr/src/wrk2-cache-stresser
RUN cd wrk2-cache-stresser && \
    make clean && \
    make -j && \
    strip wrk



FROM ${ARCH}alpine
MAINTAINER Kinvolk

RUN apk add --update --no-cache expect curl util-linux \
                        so:libcrypto.so.1.1 so:libssl.so.1.1 so:libgcc_s.so.1

COPY --from=builder /usr/src/wrk2-cache-stresser/wrk /usr/local/bin/
COPY --from=builder /usr/local/lib/lua/ /usr/local/lib/lua/
COPY --from=builder /usr/local/share/lua/ /usr/local/share/lua/
COPY --from=builder /usr/src/wrk2-cache-stresser/scripts/multiple-endpoints-prometheus-metrics.lua /usr/local/bin/

RUN mkdir /tmpfs

COPY ./docker/prometheus-export-wrapper /usr/local/bin/

ENTRYPOINT ["/usr/local/bin/prometheus-export-wrapper"]
