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

Changes to add ARM support #4

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
40 changes: 33 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,19 @@ else
GOBIN=$(shell go env GOBIN)
endif

# Construct the build argument based on current Architecture (ARM or AMD)
ARCH := $(shell uname -m)
ifeq ($(ARCH),x86_64)
EXEC_DIR_PATH:= bin/linux_amd64
BUILD_CMD:= go-build-linux-amd
BUILD_CMD_DEBUG:= go-build-linux-amd-debug
BASE_IMAGE ?= ghcr.io/verrazzano/verrazzano-base:v1.0.0-20230327155846-4653b27@sha256:e82f7e630719a9f5a7309c41773385b273ec749f0e1ded96baa1a3f7a7e576e0
else ifeq ($(ARCH),aarch64)
EXEC_DIR_PATH:= bin/linux_arm64
BUILD_CMD:= go-build-linux-arm
BUILD_CMD_DEBUG:= go-build-linux-arm-debug
BASE_IMAGE ?= ghcr.io/oracle/oraclelinux:8-slim
endif


# Setting SHELL to bash allows bash commands to be executed by recipes.
Expand All @@ -40,7 +53,6 @@ SHELL = /usr/bin/env bash -o pipefail

NAME ?= cert-manager-webhook-oci
REPO_NAME:=cert-manager-webhook-oci
BASE_IMAGE ?= ghcr.io/verrazzano/verrazzano-base:v1.0.0-20230327155846-4653b27@sha256:e82f7e630719a9f5a7309c41773385b273ec749f0e1ded96baa1a3f7a7e576e0

CREATE_LATEST_TAG=0
DOCKER_IMAGE_TAG ?= local-$(shell git rev-parse --short HEAD)
Expand Down Expand Up @@ -90,30 +102,44 @@ go-build:
-o bin/$(shell uname)_$(shell uname -m)/${NAME} \
main.go

.PHONY: go-build-linux
go-build-linux:
.PHONY: go-build-linux-amd
go-build-linux-amd:
GOOS=linux GOARCH=amd64 $(GO) build \
-ldflags "-s -w ${GO_LDFLAGS}" \
-o bin/linux_amd64/${NAME} \
main.go

.PHONY: go-build-linux-debug
go-build-linux-debug:
.PHONY: go-build-linux-amd-debug
go-build-linux-amd-debug:
GOOS=linux GOARCH=amd64 $(GO) build \
-ldflags "${GO_LDFLAGS}" \
-o out/linux_amd64/${NAME} \
main.go

.PHONY: go-build-linux-arm
go-build-linux-arm:
GOOS=linux GOARCH=arm64 $(GO) build \
-ldflags "-s -w ${GO_LDFLAGS}" \
-o bin/linux_arm64/${NAME} \
main.go

.PHONY: go-build-linux-arm-debug
go-build-linux-arm-debug:
GOOS=linux GOARCH=arm64 $(GO) build \
-ldflags "${GO_LDFLAGS}" \
-o out/linux_arm64/${NAME} \
main.go

.PHONY: docker-build
docker-build: go-build-linux docker-build-common
docker-build: $(BUILD_CMD) docker-build-common

.PHONY: docker-build-common
docker-build-common:
@echo Building ${NAME} image ${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG}
docker build --pull \
--build-arg BASE_IMAGE=${BASE_IMAGE} \
--build-arg EXEC_NAME=${NAME} \
--build-arg EXEC_DIR=bin/linux_amd64 \
--build-arg EXEC_DIR=${EXEC_DIR_PATH} \
-t ${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG} .

.PHONY: docker-push
Expand Down