# syntax=docker/dockerfile:1.0

## STAGE 1: Build the static iperf3 binary
FROM alpine:edge AS build
ARG VERSION=master
RUN apk add --no-cache build-base git
RUN git clone --depth 1 --branch ${VERSION} https://github.com/esnet/iperf
RUN iperf/configure CFLAGS="-Os -s" --enable-static-bin
RUN make -j12
RUN mkdir /empty

## STAGE 2: Build the container proper
FROM scratch
COPY --from=build /src/iperf3 /bin/
COPY --from=build /empty/ /tmp/

# Start it as a server.
EXPOSE 5201/tcp 5201/udp
ENTRYPOINT [ "/bin/iperf3" ]
CMD [ "-s" ]
