Skip to content

Commit

Permalink
Update: Enable arm64 kfctl binary build and fix docker build error (k…
Browse files Browse the repository at this point in the history
…ubeflow#349)

1. Adds support for building and releasing arm64 kfctl binary.
   Note: This updated PR used a safer support method without
   changing current building targets and release names.
2. Fixes building error for target `build-kfctl-container`
when executing `RUN go mod download` by upgrading the Golang
version to v1.13.7.
3. Only installing google-cloud on x86_64 machines.

Signed-off-by: Henry Wang <[email protected]>
  • Loading branch information
MrXinWang authored and vpavlin committed Jul 10, 2020
1 parent e22b970 commit f77bbc9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
18 changes: 11 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#**********************************************************************
# Builder
# Create a go runtime suitable for building and testing kfctl
ARG GOLANG_VERSION=1.12.7
ARG GOLANG_VERSION=1.13.7
FROM golang:$GOLANG_VERSION as builder

ARG BRANCH=master
Expand All @@ -14,11 +14,12 @@ RUN apt-get install -y git unzip jq vim
RUN go get -u github.com/jstemmer/go-junit-report

# We need gcloud to get gke credentials.
RUN \
cd /tmp && \
wget -nv https://dl.google.com/dl/cloudsdk/release/install_google_cloud_sdk.bash && \
chmod +x install_google_cloud_sdk.bash && \
./install_google_cloud_sdk.bash --disable-prompts --install-dir=/opt/
RUN if [ "$(uname -m)" = "x86_64" ]; then \
cd /tmp && \
wget -nv https://dl.google.com/dl/cloudsdk/release/install_google_cloud_sdk.bash && \
chmod +x install_google_cloud_sdk.bash && \
./install_google_cloud_sdk.bash --disable-prompts --install-dir=/opt/; \
fi

ENV PATH /go/bin:/usr/local/go/bin:/opt/google-cloud-sdk/bin:${PATH}

Expand Down Expand Up @@ -49,7 +50,10 @@ COPY . .
#
FROM builder as kfctl_base

RUN make build-kfctl
RUN make build-kfctl && \
if [ "$(uname -m)" = "aarch64" ]; then \
cp bin/arm64/kfctl bin/kfctl; \
fi

#**********************************************************************
#
Expand Down
22 changes: 15 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.
#
GCLOUD_PROJECT ?= kubeflow-images-public
GOLANG_VERSION ?= 1.12.7
GOLANG_VERSION ?= 1.13.7
GOPATH ?= $(HOME)/go
# To build without the cache set the environment variable
# export DOCKER_BUILD_OPTS=--no-cache
Expand Down Expand Up @@ -126,22 +126,24 @@ build: build-kfctl

build-kfctl: deepcopy generate fmt vet
# TODO(swiftdiaries): figure out import conflict errors for windows
#GOOS=windows GOARCH=amd64 ${GO} build -gcflags '-N -l' -ldflags "-X main.VERSION=$(TAG)" -o bin/windows/kfctl.exe cmd/kfctl/main.go
GOOS=darwin GOARCH=amd64 ${GO} build -gcflags '-N -l' -ldflags "-X main.VERSION=${TAG}" -o bin/darwin/kfctl cmd/kfctl/main.go
GOOS=linux GOARCH=amd64 ${GO} build -gcflags '-N -l' -ldflags "-X main.VERSION=$(TAG)" -o bin/linux/kfctl cmd/kfctl/main.go
#CGO_ENABLED=0 GOOS=windows GOARCH=amd64 ${GO} build -gcflags '-N -l' -ldflags "-X main.VERSION=$(TAG)" -o bin/windows/kfctl.exe cmd/kfctl/main.go
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 ${GO} build -gcflags '-N -l' -ldflags "-X main.VERSION=${TAG}" -o bin/darwin/kfctl cmd/kfctl/main.go
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 ${GO} build -gcflags '-N -l' -ldflags "-X main.VERSION=$(TAG)" -o bin/linux/kfctl cmd/kfctl/main.go
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 ${GO} build -gcflags '-N -l' -ldflags "-X main.VERSION=$(TAG)" -o bin/arm64/kfctl cmd/kfctl/main.go
cp bin/$(ARCH)/kfctl bin/kfctl

# Fast rebuilds useful for development.
# Does not regenerate code; assumes you already ran build-kfctl once.
build-kfctl-fast: fmt vet
GOOS=linux GOARCH=amd64 ${GO} build -gcflags '-N -l' -ldflags "-X main.VERSION=$(TAG)" -o bin/linux/kfctl cmd/kfctl/main.go
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 ${GO} build -gcflags '-N -l' -ldflags "-X main.VERSION=$(TAG)" -o bin/linux/kfctl cmd/kfctl/main.go

# Release tarballs suitable for upload to GitHub release pages
build-kfctl-tgz: build-kfctl
chmod a+rx ./bin/kfctl
rm -f bin/*.tgz
cd bin/linux && tar -cvzf kfctl_$(TAG)_linux.tar.gz ./kfctl
cd bin/darwin && tar -cvzf kfctl_${TAG}_darwin.tar.gz ./kfctl
cd bin/arm64 && tar -cvzf kfctl_${TAG}_arm64.tar.gz ./kfctl

build-and-push-operator: build-operator push-operator
build-push-update-operator: build-operator push-operator update-operator-image
Expand Down Expand Up @@ -190,13 +192,19 @@ push-to-github-release: build-kfctl-tgz
--repo kubeflow \
--tag $(TAG) \
--name "kfctl_$(TAG)_linux.tar.gz" \
--file bin/kfctl_$(TAG)_linux.tar.gz
--file bin/linux/kfctl_$(TAG)_linux.tar.gz
github-release upload \
--user kubeflow \
--repo kubeflow \
--tag $(TAG) \
--name "kfctl_$(TAG)_darwin.tar.gz" \
--file bin/kfctl_$(TAG)_darwin.tar.gz
--file bin/darwin/kfctl_$(TAG)_darwin.tar.gz
github-release upload \
--user kubeflow \
--repo kubeflow \
--tag $(TAG) \
--name "kfctl_$(TAG)_arm64.tar.gz" \
--file bin/arm64/kfctl_$(TAG)_arm64.tar.gz

build-kfctl-container:
DOCKER_BUILDKIT=1 docker build \
Expand Down

0 comments on commit f77bbc9

Please sign in to comment.