build: check if installed Golang has a compatible architecture

For building a arm64 container image on amd64, it is needed to configure
the system specifically for that. In order to prevent including a amd64
executable in a arm64 image, a check has been added.

When running an arm64 executable on a amd64 system, an error should
occur when cross architecture containers are not supported. This can be
triggered when running `make image-cephcsi GO_ARCH=arm64` on a amd64
system.

Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
Niels de Vos 2020-06-22 17:08:07 +02:00 committed by mergify[bot]
parent 44bf398c79
commit 2055d79165

View File

@ -19,6 +19,9 @@ RUN source /build.env && \
mkdir -p ${GOROOT} && \
curl https://storage.googleapis.com/golang/go${GOLANG_VERSION}.linux-${GO_ARCH}.tar.gz | tar xzf - -C ${GOROOT} --strip-components=1
# test if the downloaded version of Golang works (different arch?)
RUN ${GOROOT}/bin/go version && ${GOROOT}/bin/go env
RUN dnf install libcephfs-devel librados-devel librbd-devel /usr/bin/cc make -y
ENV GOROOT=${GOROOT} \