-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add golang Dockerfile to build goharbor/golang image
Signed-off-by: Shengwen Yu <yshengwen@vmware.com>
- Loading branch information
Shengwen Yu
committed
Jul 4, 2024
1 parent
d07a7ac
commit 965f450
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
FROM photon:4.0 | ||
|
||
ARG GOVERSION | ||
|
||
# install cgo-related dependencies && git | ||
# official golang build from standard Debian, while photon os do not install git as default | ||
RUN tdnf install build-essential git gpg -y | ||
|
||
ENV PATH /usr/local/go/bin:$PATH | ||
|
||
ENV GOLANG_VERSION ${GOVERSION} | ||
|
||
RUN set eux; \ | ||
url="https://dl.google.com/go/go${GOLANG_VERSION}.linux-amd64.tar.gz"; \ | ||
sha256="904b924d435eaea086515bc63235b192ea441bd8c9b198c507e85009e6e4c7f0"; \ | ||
wget -O go.tgz.asc "$url.asc"; \ | ||
wget -O go.tgz "$url"; \ | ||
echo "$sha256 *go.tgz" | sha256sum -c -; \ | ||
# https://github.com/golang/go/issues/14739#issuecomment-324767697 | ||
GNUPGHOME="$(mktemp -d)"; export GNUPGHOME; \ | ||
# https://www.google.com/linuxrepositories/ | ||
gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 'EB4C 1BFD 4F04 2F6D DDCC EC91 7721 F63B D38B 4796'; \ | ||
# let's also fetch the specific subkey of that key explicitly that we expect "go.tgz.asc" to be signed by, just to make sure we definitely have it | ||
gpg --batch --keyserver keyserver.ubuntu.com --recv-keys '2F52 8D36 D67B 69ED F998 D857 78BD 6547 3CB3 BD13'; \ | ||
gpg --batch --verify go.tgz.asc go.tgz; \ | ||
gpgconf --kill all; \ | ||
rm -rf "$GNUPGHOME" go.tgz.asc; \ | ||
tar -C /usr/local -xzf go.tgz; \ | ||
rm go.tgz; \ | ||
go version | ||
|
||
ENV GOPATH /go | ||
ENV PATH $GOPATH/bin:$PATH | ||
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 1777 "$GOPATH" | ||
WORKDIR $GOPATH |