FROM golang:1.23-bookworm SHELL ["bash", "-Eeuo", "pipefail", "-xc"] RUN apt-get update; \ apt-get install -y --no-install-recommends \ file \ gnupg \ wget \ ; \ rm -rf /var/lib/apt/lists/* WORKDIR /usr/src/bashbrew ENV CGO_ENABLED 0 ENV BASHBREW_ARCHES \ amd64 \ arm32v5 \ arm32v6 \ arm32v7 \ arm64v8 \ darwin-amd64 \ i386 \ mips64le \ ppc64le \ riscv64 \ s390x \ windows-amd64 COPY scripts/bashbrew-arch-to-goenv.sh /usr/local/bin/ # https://github.com/estesp/manifest-tool/releases ENV MANIFEST_TOOL_VERSION 1.0.2 # gpg: key 0F386284C03A1162: public key "Philip Estes " imported ENV MANIFEST_TOOL_GPG_KEY 27F3EA268A97867EAF0BD05C0F386284C03A1162 RUN export GNUPGHOME="$(mktemp -d)"; \ gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$MANIFEST_TOOL_GPG_KEY"; \ \ mkdir -p bin; \ \ for bashbrewArch in $BASHBREW_ARCHES; do \ # TODO convince estesp to release riscv64 binaries (https://github.com/estesp/manifest-tool/pull/113 👀) if [ "$bashbrewArch" = 'riscv64' ]; then continue; fi; \ ( \ goEnv="$(bashbrew-arch-to-goenv.sh "$bashbrewArch")"; eval "$goEnv"; \ srcBin="manifest-tool-$GOOS-$GOARCH"; \ if [ "$GOARCH" = 'arm' ]; then [ -n "$GOARM" ]; srcBin="${srcBin}v$GOARM"; fi; \ [ "$GOOS" = 'windows' ] && ext='.exe' || ext=; \ srcBin="$srcBin$ext"; \ targetBin="bin/manifest-tool-$bashbrewArch$ext"; \ wget -O "$targetBin.asc" "https://github.com/estesp/manifest-tool/releases/download/v${MANIFEST_TOOL_VERSION}/$srcBin.asc"; \ wget -O "$targetBin" "https://github.com/estesp/manifest-tool/releases/download/v${MANIFEST_TOOL_VERSION}/$srcBin" --progress=dot:giga; \ gpg --batch --verify "$targetBin.asc" "$targetBin"; \ ls -lAFh "$targetBin"*; \ file "$targetBin"*; \ ) \ done; \ \ gpgconf --kill all; \ rm -r "$GNUPGHOME"; \ \ ls -lAFh bin/manifest-tool-*; \ file bin/manifest-tool-* COPY go.mod go.sum ./ RUN go mod download COPY . . RUN for bashbrewArch in $BASHBREW_ARCHES; do \ ( \ goEnv="$(bashbrew-arch-to-goenv.sh "$bashbrewArch")"; eval "$goEnv"; \ [ "$GOOS" = 'windows' ] && ext='.exe' || ext=; \ \ LDFLAGS='-s -w'; \ case "$GOOS" in \ darwin | windows) ;; \ *) LDFLAGS+=' -d' ;; \ esac; \ \ targetBin="bin/bashbrew-$bashbrewArch$ext"; \ go build \ -v -ldflags "$LDFLAGS" \ -tags netgo -installsuffix netgo \ -o "$targetBin" \ ./cmd/bashbrew \ ; \ ls -lAFh "$targetBin"; \ file "$targetBin"; \ ) \ done; \ \ ls -lAFh bin/bashbrew-*; \ file bin/bashbrew-*