redisLoadTest/Dockerfile

35 lines
724 B
Docker

FROM golang:1.17.5-bullseye AS builder
RUN mkdir /tmp/redisloadtest
WORKDIR /tmp/redisloadtest
COPY go.mod .
COPY go.sum .
COPY redisLoadTest.go .
RUN set -ex \
&& go build -o redisLoadTest redisLoadTest.go
FROM golang:1.17.5-bullseye AS redisloadtest
ENV USER=redisloadtest
ENV FILEPATH=/usr/local/bin/
ENV FILENAME=redisLoadTest
ENV HOME=/home/${USER}
RUN useradd ${USER} --home-dir ${HOME}
WORKDIR /tmp
# Copy the binary from the builder stage
COPY --from=builder /tmp/redisloadtest/${FILENAME} ./
RUN mv /tmp/${FILENAME} ${FILEPATH} \
&& chown ${USER}:${USER} ${FILEPATH}${FILENAME} \
&& chmod 4555 ${FILEPATH}${FILENAME} \
&& rm -rf -- /tmp/* \
WORKDIR ${HOME}
CMD ["${FILEPATH}${FILENAME}"]