# Dockerfile (4:31)
FROM alpine:3.20.3 as deps
ARG GO_APP
ARG GORELEASER_DIST_DIR=/go/src/dist
ARG TARGETOS
ARG TARGETARCH
ARG TARGETVARIANT
RUN mkdir -p /go/bin /go/src ${GORELEASER_DIST_DIR}
COPY --from=build ${GORELEASER_DIST_DIR}/ ${GORELEASER_DIST_DIR}
RUN <<EOT
set -e
apk add --no-cache ca-certificates jq
cd ${GORELEASER_DIST_DIR}/..
if [[ ${TARGETARCH} == "arm" ]]; then VARIANT=$(echo ${TARGETVARIANT} | sed 's/^v//'); fi
BIN_PATH=$(jq -r ".[] |select(.type == \"Binary\" and \
.name == \"${GO_APP}\" and \
.goos == \"${TARGETOS}\" and \
.goarch == \"${TARGETARCH}\" and \
(.goarm == \"${VARIANT}\" or .goarm == null)) | .path" < /go/src/dist/artifacts.json)
cp ${BIN_PATH} /go/bin
EOT
FROM alpine:3.20.3