Skip to content

Commit

Permalink
NO-ISSUE: moving images to be multiplatform
Browse files Browse the repository at this point in the history
  • Loading branch information
tsorya committed Jun 28, 2021
1 parent 3de7598 commit aec2c75
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
12 changes: 9 additions & 3 deletions Dockerfile.assisted-installer
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
FROM registry.ci.openshift.org/openshift/release:golang-1.15 AS builder
FROM --platform=$BUILDPLATFORM golang:1.15 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

Expand All @@ -9,9 +14,10 @@ COPY go.sum go.sum
RUN go mod download

COPY . .
RUN make installer

FROM quay.io/centos/centos:centos8
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
Expand Down
12 changes: 8 additions & 4 deletions Dockerfile.assisted-installer-controller
Original file line number Diff line number Diff line change
@@ -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.15 AS builder
FROM --platform=$BUILDPLATFORM golang:1.15 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
Expand All @@ -11,9 +14,10 @@ COPY go.sum go.sum
RUN go mod download

COPY . .
RUN make controller

FROM quay.io/centos/centos:centos8
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
Expand Down
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit aec2c75

Please sign in to comment.