diff --git a/Dockerfile.assisted-installer b/Dockerfile.assisted-installer index 37f667ce6..0f05aea40 100644 --- a/Dockerfile.assisted-installer +++ b/Dockerfile.assisted-installer @@ -1,4 +1,9 @@ -FROM registry.ci.openshift.org/openshift/release:golang-1.16 AS builder +FROM --platform=$BUILDPLATFORM golang:1.16 AS builder + +ARG TARGETPLATFORM + +WORKDIR /go/src/github.com/openshift/assisted-installer-agent + ENV GOFLAGS=-mod=mod WORKDIR /go/src/github.com/openshift/assisted-installer @@ -9,9 +14,10 @@ COPY go.sum go.sum RUN go mod download COPY . . -RUN make installer -FROM quay.io/centos/centos:stream8 +RUN if [ "$TARGETPLATFORM" = "linux/arm64" ]; then GO_BUILD_ENV_PARAMS="GOOS=linux GOARCH=arm64" make installer;else make installer; fi + +FROM --platform=$TARGETPLATFORM quay.io/centos/centos:centos8 COPY --from=builder /go/src/github.com/openshift/assisted-installer/build/installer /usr/bin/installer COPY --from=builder /go/src/github.com/openshift/assisted-installer/deploy/assisted-installer-controller /assisted-installer-controller/deploy diff --git a/Dockerfile.assisted-installer-controller b/Dockerfile.assisted-installer-controller index 2e10c906b..367db08c3 100644 --- a/Dockerfile.assisted-installer-controller +++ b/Dockerfile.assisted-installer-controller @@ -1,7 +1,10 @@ -FROM quay.io/openshift/origin-cli:4.9.0 AS cli +FROM --platform=$BUILDPLATFORM quay.io/openshift/origin-cli:4.9.0 AS cli -FROM registry.ci.openshift.org/openshift/release:golang-1.16 AS builder +FROM --platform=$BUILDPLATFORM golang:1.16 AS builder + +ARG TARGETPLATFORM ENV GOFLAGS=-mod=mod + WORKDIR /go/src/github.com/openshift/assisted-installer # Bring in the go dependencies before anything else so we can take @@ -11,9 +14,10 @@ COPY go.sum go.sum RUN go mod download COPY . . -RUN make controller -FROM quay.io/centos/centos:stream8 +RUN if [ "$TARGETPLATFORM" = "linux/arm64" ]; then GO_BUILD_ENV_PARAMS="GOOS=linux GOARCH=arm64" make controller;else make controller; fi + +FROM --platform=$TARGETPLATFORM quay.io/centos/centos:centos8 RUN yum -y install make gcc unzip wget curl rsync && yum clean all COPY --from=builder /go/src/github.com/openshift/assisted-installer/build/assisted-installer-controller /usr/bin/assisted-installer-controller diff --git a/Makefile b/Makefile index b4940cd21..641ba3042 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ NAMESPACE := $(or ${NAMESPACE},assisted-installer) GIT_REVISION := $(shell git rev-parse HEAD) PUBLISH_TAG := $(or ${GIT_REVISION}) -CONTAINER_BUILD_PARAMS = --network=host --label git_revision=${GIT_REVISION} +CONTAINER_BUILD_PARAMS = --label git_revision=${GIT_REVISION} REPORTS ?= $(ROOT_DIR)/reports CI ?= false @@ -53,18 +53,18 @@ endif build: installer controller installer: - CGO_ENABLED=0 go build -o build/installer src/main/main.go + $(GO_BUILD_ENV_PARAMS) CGO_ENABLED=0 go build -o build/installer src/main/main.go controller: - CGO_ENABLED=0 go build -o build/assisted-installer-controller src/main/assisted-installer-controller/assisted_installer_main.go + $(GO_BUILD_ENV_PARAMS) CGO_ENABLED=0 go build -o build/assisted-installer-controller src/main/assisted-installer-controller/assisted_installer_main.go build-images: installer-image controller-image installer-image: - $(CONTAINER_COMMAND) build $(CONTAINER_BUILD_PARAMS) -f Dockerfile.assisted-installer . -t $(INSTALLER) + docker buildx build --platform=linux/arm64,linux/amd64 $(CONTAINER_BUILD_PARAMS) -f Dockerfile.assisted-installer . -t $(INSTALLER) --push controller-image: - $(CONTAINER_COMMAND) build $(CONTAINER_BUILD_PARAMS) -f Dockerfile.assisted-installer-controller . -t $(CONTROLLER) + docker buildx build --platform=linux/arm64,linux/amd64 $(CONTAINER_BUILD_PARAMS) -f Dockerfile.assisted-installer-controller . -t $(CONTROLLER) --push push-installer: installer-image $(CONTAINER_COMMAND) push $(INSTALLER)