FROM --platform=linux/amd64 050879227952.dkr.ecr.us-west-1.amazonaws.com/confluentinc/cli-centos-base-amd64:latest

COPY . /cli/

RUN export GO_VERSION=$(cat /cli/.go-version) && \
    wget "https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz" && \
    sudo tar -C /usr/local -xzf "go${GO_VERSION}.linux-amd64.tar.gz"

ENV PATH=${PATH}:/usr/local/go/bin:/root/go/bin

RUN --mount=type=secret,id=deb_gpg_secret_key --mount=type=secret,id=deb_gpg_passphrase --mount=type=secret,id=rpm_gpg_secret_key --mount=type=secret,id=rpm_gpg_passphrase \
    export NFPM_DEFAULT_DEB_PASSPHRASE=$(cat /run/secrets/deb_gpg_passphrase) && \
    export NFPM_DEFAULT_RPM_PASSPHRASE=$(cat /run/secrets/rpm_gpg_passphrase) && \
    cd /cli && \
    make gorelease-linux-amd64
