Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makefile: support aarch64/arm64 build #2194

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 23 additions & 13 deletions src/cloud-api-adaptor/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,22 @@ include Makefile.defaults

SHELL = bash -o pipefail

ARCH ?= $(subst x86_64,amd64,$(shell uname -m))
ARCH ?= $(shell uname -m)
TARGET_ARCH ?= amd64
PROTOC_ARCH ?= x86_64
ifeq ($(ARCH),aarch64)
TARGET_ARCH := arm64
PROTOC_ARCH := aarch_64
else ifeq ($(ARCH),s390x)
TARGET_ARCH := s390x
PROTOC_ARCH := s390_64
endif

# Default is dev build. To create release build set RELEASE_BUILD=true
RELEASE_BUILD ?= false
# CLOUD_PROVIDER is used for runtime -- which provider should be run against the binary/code.
CLOUD_PROVIDER ?=
GOOPTIONS ?= GOOS=linux GOARCH=$(ARCH) CGO_ENABLED=0
GOOPTIONS ?= GOOS=linux GOARCH=$(TARGET_ARCH) CGO_ENABLED=0
GOFLAGS ?=
BINARIES := cloud-api-adaptor agent-protocol-forwarder process-user-data
SOURCEDIRS := ./cmd ./pkg
Expand All @@ -24,7 +34,7 @@ TEST_E2E_TIMEOUT ?= 60m
RUN_TESTS ?= ''

RESOURCE_CTRL ?= true
YQ_CHECKSUM_${ARCH} ?= $(YQ_CHECKSUM)
YQ_CHECKSUM_$(TARGET_ARCH) ?= $(YQ_CHECKSUM)
# BUILTIN_CLOUD_PROVIDERS is used for binary build -- what providers are built in the binaries.
ifeq ($(RELEASE_BUILD),true)
BUILTIN_CLOUD_PROVIDERS ?= aws azure gcp ibmcloud vsphere
Expand Down Expand Up @@ -112,11 +122,11 @@ clean: ## Remove binaries.

.PHONY: image
image: .git-commit ## Build and push docker image to $registry
COMMIT=$(COMMIT) VERSION=$(VERSION) YQ_VERSION=$(YQ_VERSION) YQ_CHECKSUM=$(YQ_CHECKSUM) hack/build.sh -i
COMMIT=$(COMMIT) VERSION=$(VERSION) YQ_VERSION=$(YQ_VERSION) hack/build.sh -i

.PHONY: image-with-arch
image-with-arch: .git-commit ## Build the per arch image
COMMIT=$(COMMIT) VERSION=$(VERSION) YQ_VERSION=$(YQ_VERSION) YQ_CHECKSUM=$(YQ_CHECKSUM) hack/build.sh -a
COMMIT=$(COMMIT) VERSION=$(VERSION) YQ_VERSION=$(YQ_VERSION) hack/build.sh -a

##@ Deployment

Expand Down Expand Up @@ -162,8 +172,8 @@ PODVM_DISTRO ?= ubuntu
PODVM_TAG ?= $(VERSIONS_HASH)

PODVM_BUILDER_IMAGE ?= $(REGISTRY)/podvm-builder-$(PODVM_DISTRO):$(PODVM_TAG)
PODVM_BINARIES_IMAGE ?= $(REGISTRY)/podvm-binaries-$(PODVM_DISTRO)-$(ARCH):$(PODVM_TAG)
PODVM_IMAGE ?= $(REGISTRY)/podvm-$(or $(CLOUD_PROVIDER),generic)-$(PODVM_DISTRO)-$(ARCH):$(PODVM_TAG)
PODVM_BINARIES_IMAGE ?= $(REGISTRY)/podvm-binaries-$(PODVM_DISTRO)-$(TARGET_ARCH):$(PODVM_TAG)
PODVM_IMAGE ?= $(REGISTRY)/podvm-$(or $(CLOUD_PROVIDER),generic)-$(PODVM_DISTRO)-$(TARGET_ARCH):$(PODVM_TAG)

PUSH ?= false
# If not pushing `--load` into the local docker cache
Expand All @@ -179,12 +189,12 @@ podvm-builder:
--build-arg GO_VERSION=$(GO_VERSION) \
--build-arg ORG_ID=$(ORG_ID) \
--build-arg ACTIVATION_KEY=$(ACTIVATION_KEY) \
--build-arg ARCH=$(ARCH) \
--build-arg ARCH=$(TARGET_ARCH) \
--build-arg PROTOC_VERSION=$(PROTOC_VERSION) \
--build-arg YQ_VERSION=$(YQ_VERSION) \
--build-arg YQ_CHECKSUM=${YQ_CHECKSUM_$(ARCH)} \
--build-arg YQ_ARCH=$(ARCH) \
--build-arg PROTOC_ARCH=$(if $(filter amd64,$(ARCH)),x86_64,s390_64) \
--build-arg YQ_CHECKSUM=${YQ_CHECKSUM_$(TARGET_ARCH)} \
--build-arg YQ_ARCH=$(TARGET_ARCH) \
--build-arg PROTOC_ARCH=$(PROTOC_ARCH) \
--build-arg ORAS_VERSION=$(ORAS_VERSION) \
--build-arg PACKER_VERSION=$(PACKER_VERSION) \
$(DOCKER_OPTS) .
Expand All @@ -194,7 +204,7 @@ podvm-binaries:
cd ../ && docker buildx build -t $(PODVM_BINARIES_IMAGE) -f cloud-api-adaptor/podvm/$(BINARIES_DOCKERFILE) \
--build-arg BUILDER_IMG=$(PODVM_BUILDER_IMAGE) \
--build-arg PODVM_DISTRO=$(PODVM_DISTRO) \
--build-arg ARCH=$(ARCH) \
--build-arg ARCH=$(TARGET_ARCH) \
--build-arg TEE_PLATFORM=$(TEE_PLATFORM) \
--build-arg PAUSE_REPO=$(PAUSE_REPO) \
--build-arg PAUSE_VERSION=$(PAUSE_VERSION) \
Expand All @@ -217,7 +227,7 @@ endif
--build-arg BUILDER_IMG=$(PODVM_BUILDER_IMAGE) \
--build-arg BINARIES_IMG=$(PODVM_BINARIES_IMAGE) \
--build-arg PODVM_DISTRO=$(PODVM_DISTRO) \
--build-arg ARCH=$(ARCH) \
--build-arg ARCH=$(TARGET_ARCH) \
--build-arg CLOUD_PROVIDER=$(or $(CLOUD_PROVIDER),generic) \
--build-arg IMAGE_URL=$(IMAGE_URL) \
--build-arg IMAGE_CHECKSUM=$(IMAGE_CHECKSUM) \
Expand Down
3 changes: 3 additions & 0 deletions src/cloud-api-adaptor/Makefile.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ PAUSE_BIN ?= pause
YQ_VERSION := v4.35.1
YQ_CHECKSUM := "sha256:bd695a6513f1196aeda17b174a15e9c351843fb1cef5f9be0af170f2dd744f08"
YQ_CHECKSUM_s390x := "sha256:4e6324d08630e7df733894a11830412a43703682d65a76f1fc925aac08268a45"
YQ_CHECKSUM_arm64 := "sha256:1d830254fe5cc2fb046479e6c781032976f5cf88f9d01a6385898c29182f9bed"
# none,az-cvm-vtpm,tdx,se,cca
TEE_PLATFORM ?= none

Expand All @@ -25,6 +26,8 @@ ubuntu_amd64_IMAGE_URL := $(call query,cloudimg.ubuntu.$(ubuntu_RELEASE).amd64.u
ubuntu_amd64_IMAGE_CHECKSUM := $(call query,cloudimg.ubuntu.$(ubuntu_RELEASE).amd64.checksum)
ubuntu_s390x_IMAGE_URL := $(call query,cloudimg.ubuntu.$(ubuntu_RELEASE).s390x.url)
ubuntu_s390x_IMAGE_CHECKSUM := $(call query,cloudimg.ubuntu.$(ubuntu_RELEASE).s390x.checksum)
ubuntu_arm64_IMAGE_URL := $(call query,cloudimg.ubuntu.$(ubuntu_RELEASE).arm64.url)
ubuntu_arm64_IMAGE_CHECKSUM := $(call query,cloudimg.ubuntu.$(ubuntu_RELEASE).arm64.checksum)
rhel_amd64_IMAGE_URL := $(call query,cloudimg.rhel.$(rhel_RELEASE).amd64.url)
rhel_amd64_IMAGE_CHECKSUM := $(call query,cloudimg.rhel.$(rhel_RELEASE).amd64.checksum)
rhel_s390x_IMAGE_URL := $(call query,cloudimg.rhel.$(rhel_RELEASE).s390x.url)
Expand Down
2 changes: 0 additions & 2 deletions src/cloud-api-adaptor/hack/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ function build_caa_payload_image() {
--build-arg VERSION="${version}" \
--build-arg COMMIT="${commit}" \
--build-arg YQ_VERSION="${YQ_VERSION}" \
--build-arg YQ_CHECKSUM="${YQ_CHECKSUM}" \
-f cloud-api-adaptor/Dockerfile \
${tag_string} \
--push \
Expand Down Expand Up @@ -100,7 +99,6 @@ function build_caa_payload_arch_specific() {
--build-arg VERSION="${version}" \
--build-arg COMMIT="${commit}" \
--build-arg YQ_VERSION="${YQ_VERSION}" \
--build-arg YQ_CHECKSUM="${YQ_CHECKSUM}" \
-f cloud-api-adaptor/Dockerfile \
${tag_string} \
--push \
Expand Down
3 changes: 3 additions & 0 deletions src/cloud-api-adaptor/versions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ cloudimg:
s390x:
url: https://cloud-images.ubuntu.com/releases/focal/release-20230107/ubuntu-20.04-server-cloudimg-s390x.img
checksum: "sha256:24673aa86785573d3a92e15166ff81beff88cbb0abc01938f156eb1332e87cd3"
arm64:
url: https://cloud-images.ubuntu.com/releases/focal/release-20230107/ubuntu-20.04-server-cloudimg-arm64.img
checksum: "sha256:5bb6152947fa566d6ab40dc2e5b849aea3e07ab7e1c113d00372a7f99b950cae"
rhel:
9: # dummy links, get trial image from: https://www.redhat.com/en/technologies/linux-platforms/enterprise-linux/server/trial
amd64:
Expand Down
Loading