Skip to content

Commit

Permalink
operator: build multi-arch images for peerpod-ctl
Browse files Browse the repository at this point in the history
Fixes: #1432

Signed-off-by: Qi Feng Huo <huoqif@cn.ibm.com>
  • Loading branch information
Qi Feng Huo committed Sep 14, 2023
1 parent c30eaac commit ea090cd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/peerpod-ctrl_image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
push:
branches:
- main
- huoqifeng/peerpod-ctl-img
paths:
- 'peerpod-ctrl/**'

Expand All @@ -25,6 +26,10 @@ jobs:
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Install build dependencies
run: |
sudo apt-get update -y
sudo apt-get install -y libvirt-dev
- name: Login to Quay container Registry
uses: docker/login-action@v2
with:
Expand All @@ -43,6 +48,7 @@ jobs:
quay.io/confidential-containers/peerpod-ctrl:${{ github.sha }}
push: true
context: peerpod-ctrl
platforms: linux/amd64, linux/s390x
build-args: |
"$(make list-build-args)"
GOFLAGS=-tags=aws,azure,ibmcloud,vsphere,libvirt
9 changes: 5 additions & 4 deletions peerpod-ctrl/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Build the manager binary
FROM quay.io/confidential-containers/golang-fedora:1.20.7-36 as builder
FROM --platform=$TARGETPLATFORM quay.io/confidential-containers/golang-fedora:1.20.8-36 as builder
ARG TARGETOS
ARG TARGETARCH
ARG CGO_ENABLED=1
ARG GOFLAGS

WORKDIR /workspace
RUN if [ "$CGO_ENABLED" = 1 ] ; then dnf install -y libvirt-devel; fi
RUN if [ "$CGO_ENABLED" = 1 ] ; then dnf install -y libvirt-devel && dnf clean all; fi
# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum
Expand All @@ -19,16 +19,17 @@ COPY main.go main.go
COPY api/ api/
COPY controllers/ controllers/

RUN if [ "$TARGETARCH" = s390x ] ; then ln /usr/bin/gcc /usr/bin/s390x-linux-gnu-gcc; fi

# Build
# the GOARCH has not a default value to allow the binary be built according to the host where the command
# was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO
# the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore,
# by leaving it empty we can ensure that the container and binary shipped on it will have the same platform.
RUN CGO_ENABLED=${CGO_ENABLED} GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build ${GOFLAGS} -a -o manager main.go

FROM fedora:36
FROM --platform=$TARGETPLATFORM fedora:36
RUN if [ "$CGO_ENABLED" = 1 ] ; then dnf install -y libvirt-libs /usr/bin/ssh && dnf clean all; fi
RUN dnf install -y libvirt-libs /usr/bin/ssh
WORKDIR /
COPY --from=builder /workspace/manager .

Expand Down
2 changes: 1 addition & 1 deletion peerpod-ctrl/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ endif
SHELL = /usr/bin/env bash -o pipefail
.SHELLFLAGS = -ec

BUILTIN_CLOUD_PROVIDERS ?= aws azure ibmcloud libvirt
BUILTIN_CLOUD_PROVIDERS ?= aws azure ibmcloud vsphere libvirt
# Build tags required to build cloud-api-adaptor are derived from BUILTIN_CLOUD_PROVIDERS.
# When libvirt is specified, CGO_ENABLED is set to 1.
space := $() $()
Expand Down

0 comments on commit ea090cd

Please sign in to comment.