diff --git a/hack/build-image/Dockerfile b/hack/build-image/Dockerfile index dc6f26a6cb..c85a4db67e 100644 --- a/hack/build-image/Dockerfile +++ b/hack/build-image/Dockerfile @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM --platform=linux/amd64 golang:1.19-bullseye +FROM --platform=$TARGETPLATFORM golang:1.19-bullseye ARG GOPROXY @@ -21,12 +21,12 @@ ENV GO111MODULE=on ENV GOPROXY=${GOPROXY} # kubebuilder test bundle is separated from kubebuilder. Need to setup it for CI test. -RUN curl -sSLo envtest-bins.tar.gz https://go.kubebuilder.io/test-tools/1.22.1/linux/amd64 && \ +RUN curl -sSLo envtest-bins.tar.gz https://go.kubebuilder.io/test-tools/1.22.1/linux/$(go env GOARCH) && \ mkdir /usr/local/kubebuilder && \ tar -C /usr/local/kubebuilder --strip-components=1 -zvxf envtest-bins.tar.gz -RUN wget --quiet https://github.com/kubernetes-sigs/kubebuilder/releases/download/v3.2.0/kubebuilder_linux_amd64 && \ - mv kubebuilder_linux_amd64 /usr/local/kubebuilder/bin/kubebuilder && \ +RUN wget --quiet https://github.com/kubernetes-sigs/kubebuilder/releases/download/v3.2.0/kubebuilder_linux_$(go env GOARCH) && \ + mv kubebuilder_linux_$(go env GOARCH) /usr/local/kubebuilder/bin/kubebuilder && \ chmod +x /usr/local/kubebuilder/bin/kubebuilder # get controller-tools @@ -39,19 +39,30 @@ RUN go install golang.org/x/tools/cmd/goimports@11e9d9cc0042e6bd10337d4d2c3e5d92 # get protoc compiler and golang plugin WORKDIR /root RUN apt-get update && apt-get install -y unzip -RUN wget --quiet https://github.com/protocolbuffers/protobuf/releases/download/v3.14.0/protoc-3.14.0-linux-x86_64.zip && \ - unzip protoc-3.14.0-linux-x86_64.zip && \ +RUN if [ "$(go env GOARCH)" = "arm64" ] ; then \ + wget --quiet https://github.com/protocolbuffers/protobuf/releases/download/v3.14.0/protoc-3.14.0-linux-aarch_64.zip && \ + unzip protoc-3.14.0-linux-aarch_64.zip; \ + else \ + wget --quiet https://github.com/protocolbuffers/protobuf/releases/download/v3.14.0/protoc-3.14.0-linux-x86_64.zip && \ + unzip protoc-3.14.0-linux-x86_64.zip; \ + fi && \ + rm *.zip && \ mv bin/protoc /usr/bin/protoc && \ mv include/google /usr/include && \ - chmod a+x /usr/include/google && \ - chmod a+x /usr/include/google/protobuf && \ + chmod a+x /usr/include/google && \ + chmod a+x /usr/include/google/protobuf && \ chmod a+r -R /usr/include/google && \ chmod +x /usr/bin/protoc RUN go install github.com/golang/protobuf/protoc-gen-go@v1.4.3 # get goreleaser -RUN wget --quiet https://github.com/goreleaser/goreleaser/releases/download/v1.12.3/goreleaser_Linux_x86_64.tar.gz && \ - tar xvf goreleaser_Linux_x86_64.tar.gz && \ +RUN if [ "$(go env GOARCH)" = "arm64" ] ; then \ + wget --quiet "https://github.com/goreleaser/goreleaser/releases/download/v1.12.3/goreleaser_Linux_arm64.tar.gz" && \ + tar xvf goreleaser_Linux_arm64.tar.gz; \ + else \ + wget --quiet "https://github.com/goreleaser/goreleaser/releases/download/v1.12.3/goreleaser_Linux_x86_64.tar.gz" && \ + tar xvf goreleaser_Linux_x86_64.tar.gz; \ + fi && \ mv goreleaser /usr/bin/goreleaser && \ chmod +x /usr/bin/goreleaser @@ -59,6 +70,6 @@ RUN wget --quiet https://github.com/goreleaser/goreleaser/releases/download/v1.1 RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.51.0 # install kubectl -RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl +RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/$(go env GOARCH)/kubectl RUN chmod +x ./kubectl RUN mv ./kubectl /usr/local/bin