-
Notifications
You must be signed in to change notification settings - Fork 60
/
Dockerfile.release
95 lines (85 loc) · 2.52 KB
/
Dockerfile.release
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
FROM golang:1.20-bullseye
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 <[email protected]>" 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; go mod verify
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-*