FROM alpine:latest AS build
COPY archmap /
ARG TARGETARCH
ARG URIBASE
RUN set -x \
    && export ARCH=$(./archmap ${TARGETARCH}) \
    && wget -O- ${URIBASE}-${ARCH}.tgz | tar -xzf - speedtest

FROM scratch
COPY --from=build /etc/ssl/cert.pem /
COPY --from=build /speedtest /
ENTRYPOINT [ \
    "/speedtest", \
    "--accept-gdpr", \
    "--accept-license", \
    "--ca-certificate=/cert.pem" ]
CMD [ \
    "--format=human-readable", \
    "--progress=no" ]
