Skip to content

Commit

Permalink
fix: ensure image can be built on m1 macos
Browse files Browse the repository at this point in the history
When running any of the image build  make targets on an m1 macos, it fails due to
the following error: qemu-x87_64: Could not open '/lib64/ld-linux-x86-64.so.2

Specify platform to ensure build uses the correct architecture.
  • Loading branch information
JameelB committed Mar 1, 2023
1 parent 1122f01 commit 8062ff7
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ CURL ?= curl
OC ?= oc
OCM ?= ocm

# Set os specific variables
ifeq ($(shell uname -s | tr A-Z a-z), darwin)
PGHOST:="127.0.0.1"
CONTAINER_IMAGE_BUILD_PLATFORM ?= --platform linux/amd64
else
PGHOST:="172.18.0.22"
endif

GOLANGCI_LINT ?= $(LOCAL_BIN_PATH)/golangci-lint
golangci-lint:
ifeq (, $(shell which $(LOCAL_BIN_PATH)/golangci-lint 2> /dev/null))
Expand Down Expand Up @@ -159,14 +167,6 @@ openapi/spec/validate: specinstall
${SPECTRAL} lint ../../openapi/kas-fleet-manager.yaml ../../openapi/kas-fleet-manager-private-admin.yaml ;\
}



ifeq ($(shell uname -s | tr A-Z a-z), darwin)
PGHOST:="127.0.0.1"
else
PGHOST:="172.18.0.22"
endif

### Environment-sourced variables with defaults
# Can be overriden by setting environment var before running
# Example:
Expand Down Expand Up @@ -603,7 +603,7 @@ docker/login/internal:

# Build the binary and image
image/build:
$(DOCKER) --config="${DOCKER_CONFIG}" build --pull -t "$(external_image_registry)/$(image_repository):$(image_tag)" .
$(DOCKER) --config="${DOCKER_CONFIG}" build $(CONTAINER_IMAGE_BUILD_PLATFORM) --pull -t "$(external_image_registry)/$(image_repository):$(image_tag)" .
.PHONY: image/build

# Build and push the image
Expand All @@ -614,7 +614,7 @@ image/push: image/build
# build binary and image for OpenShift deployment
image/build/internal: IMAGE_TAG ?= $(image_tag)
image/build/internal:
$(DOCKER) build -t "$(shell $(OC) get route default-route -n openshift-image-registry -o jsonpath="{.spec.host}")/$(image_repository):$(IMAGE_TAG)" .
$(DOCKER) build $(CONTAINER_IMAGE_BUILD_PLATFORM) -t "$(shell $(OC) get route default-route -n openshift-image-registry -o jsonpath="{.spec.host}")/$(image_repository):$(IMAGE_TAG)" .
.PHONY: image/build/internal

# push the image to the OpenShift internal registry
Expand Down

0 comments on commit 8062ff7

Please sign in to comment.