harbor/make/photon/golang/Dockerfile
MinerYang adf8c73b3b
bump go 1.20.7 && install git for p4 base golang image (#19138)
upadte docker file

Signed-off-by: yminer <yminer@vmware.com>
2023-08-14 10:55:23 +08:00

35 lines
1.4 KiB
Docker

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="f0a87f1bcae91c4b69f8dc2bc6d7e6bfcd7524fceec130af525058c0c17b1b44"; \
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