29 lines
632 B
Docker
29 lines
632 B
Docker
|
FROM golang:1.17.5-bullseye AS builder
|
||
|
COPY go.mod .
|
||
|
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 ${FILENAME} ./
|
||
|
|
||
|
RUN mv /tmp/${FILENAME} ${FILEPATH} \
|
||
|
&& chown ${USER}:${USER} ${FILEPATH}${FILENAME} \
|
||
|
&& chmod 4555 ${FILENAME}${FILEPATH} \
|
||
|
&& rm -rf -- /tmp/* \
|
||
|
|
||
|
WORKDIR ${HOME}
|
||
|
|
||
|
CMD ["${FILEPATH}${FILENAME}"]
|