91 lines
2.3 KiB
Docker
91 lines
2.3 KiB
Docker
FROM golang:1.13-buster
|
|
|
|
SHELL ["bash", "-Eeuo", "pipefail", "-xc"]
|
|
|
|
RUN apt-get update; \
|
|
apt-get install -y --no-install-recommends \
|
|
file \
|
|
gnupg dirmngr \
|
|
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 \
|
|
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 <estesp@gmail.com>" imported
|
|
ENV MANIFEST_TOOL_GPG_KEY 27F3EA268A97867EAF0BD05C0F386284C03A1162
|
|
|
|
RUN export GNUPGHOME="$(mktemp -d)"; \
|
|
gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$MANIFEST_TOOL_GPG_KEY"; \
|
|
\
|
|
mkdir -p bin; \
|
|
\
|
|
for bashbrewArch in $BASHBREW_ARCHES; do \
|
|
( \
|
|
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 . .
|
|
|
|
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" \
|
|
-mod vendor \
|
|
./cmd/bashbrew \
|
|
; \
|
|
ls -lAFh "$targetBin"; \
|
|
file "$targetBin"; \
|
|
) \
|
|
done; \
|
|
\
|
|
ls -lAFh bin/bashbrew-*; \
|
|
file bin/bashbrew-*
|