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

Support for multiarch images #324

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/workflows/binaries-upload-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
matrix:
arch: [amd64, arm64, arm]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Build whereabouts binary
env:
GOARCH: ${{ matrix.arch }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}

- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Install kubebuilder tools
run: ./hack/install-kubebuilder-tools.sh
Expand Down
45 changes: 14 additions & 31 deletions .github/workflows/image-build.yml
Original file line number Diff line number Diff line change
@@ -1,60 +1,43 @@
name: Image build
on: [pull_request]
on: [push]
jobs:
build-amd64:
name: Image build/amd64
build-multiarch:
name: Image build
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v2

- name: Build container image
uses: docker/build-push-action@v2
uses: docker/build-push-action@v4
with:
context: .
push: false
tags: ghcr.io/${{ github.repository }}:latest-amd64
tags: ghcr.io/${{ github.repository }}:latest
file: Dockerfile
platforms: linux/arm64,linux/amd64

build-openshift:
name: Image build/openshift
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Build container image
uses: docker/build-push-action@v2
with:
context: .
push: false
tags: k8snetworkplumbingwg/whereabouts-ocp
file: Dockerfile.openshift

build-arm64:
name: Image build/arm64
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v2

- name: Build container image
uses: docker/build-push-action@v2
uses: docker/build-push-action@v4
with:
context: .
push: false
tags: ghcr.io/${{ github.repository }}:latest-arm64
file: Dockerfile.arm64
platforms: linux/arm64
tags: k8snetworkplumbingwg/whereabouts-ocp
file: Dockerfile.openshift
platforms: linux/arm64,linux/amd64
56 changes: 18 additions & 38 deletions .github/workflows/image-push-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,35 @@ name: Image push for master
on:
push:
branches:
- master
- improved-images
env:
image-push-owner: 'k8snetworkplumbingwg'
jobs:
push-amd64:
name: Image push/amd64
push:
name: Image push/ghcr
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v2

- name: Login to Container Registry
if: github.repository_owner == 'k8snetworkplumbingwg'
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push container image
if: github.repository_owner == 'k8snetworkplumbingwg'
uses: docker/build-push-action@v2
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ghcr.io/${{ github.repository }}:latest-amd64
tags: ghcr.io/${{ github.repository }}:latest
file: Dockerfile
platforms: linux/arm64,linux/amd64

push-origin:
name: Image push/origin
Expand All @@ -40,43 +39,24 @@ jobs:
- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v2

- name: Login to Container Registry
if: github.repository_owner == 'k8snetworkplumbingwg'
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push container image
if: github.repository_owner == 'k8snetworkplumbingwg'
uses: docker/build-push-action@v2
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ghcr.io/${{ github.repository }}:latest-ocp
file: Dockerfile.openshift

push-arm64:
name: Image build/arm64
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Build container image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ghcr.io/${{ github.repository }}:latest-arm64
file: Dockerfile.arm64
platforms: linux/arm64,linux/amd64
56 changes: 8 additions & 48 deletions .github/workflows/image-push-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,20 @@ env:
image-push-owner: 'k8snetworkplumbingwg'
jobs:
push-amd64:
name: Image push/amd64
name: Image push/ghcr
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v2

- name: Login to Container Registry
if: github.repository_owner == 'k8snetworkplumbingwg'
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker meta
Expand All @@ -32,50 +31,11 @@ jobs:
tag-latest: false

- name: Push container image
if: github.repository_owner == 'k8snetworkplumbingwg'
uses: docker/build-push-action@v2
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: |
${{ steps.docker_meta.outputs.tags }}-amd64
${{ steps.docker_meta.outputs.tags }}
file: Dockerfile

push-arm64:
name: Image push/arm64
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to Container Registry
if: github.repository_owner == 'k8snetworkplumbingwg'
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker meta
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v1
with:
images: ghcr.io/${{ github.repository }}
tag-latest: false

- name: Push container image
if: github.repository_owner == 'k8snetworkplumbingwg'
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: |
${{ steps.docker_meta.outputs.tags }}-arm64
file: Dockerfile
platforms: linux/arm64
platforms: linux/arm64,linux/amd64
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}

- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Get all changed files excluding docs and README
id: changed-files
Expand Down Expand Up @@ -72,12 +72,12 @@ jobs:
NUMBER_OF_COMPUTE_NODES: 5
steps:
- name: Set up Go version
uses: actions/setup-go@v1
uses: actions/setup-go@v4
with:
go-version: 1.19.x

- name: Checkout code into the Go module directory
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Get all changed files excluding docs and README
id: changed-files
Expand Down
9 changes: 5 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
FROM golang:1.19
FROM --platform=$BUILDPLATFORM golang:1.19 as builder
ADD . /usr/src/whereabouts
RUN mkdir -p $GOPATH/src/github.com/k8snetworkplumbingwg/whereabouts
WORKDIR $GOPATH/src/github.com/k8snetworkplumbingwg/whereabouts
COPY . .
RUN ./hack/build-go.sh
ARG TARGETOS TARGETARCH
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH ./hack/build-go.sh

FROM alpine:latest
LABEL org.opencontainers.image.source https://github.com/k8snetworkplumbingwg/whereabouts
COPY --from=0 /go/src/github.com/k8snetworkplumbingwg/whereabouts/bin/whereabouts .
COPY --from=0 /go/src/github.com/k8snetworkplumbingwg/whereabouts/bin/ip-control-loop .
COPY --from=builder /go/src/github.com/k8snetworkplumbingwg/whereabouts/bin/whereabouts .
COPY --from=builder /go/src/github.com/k8snetworkplumbingwg/whereabouts/bin/ip-control-loop .
COPY script/install-cni.sh .
CMD ["/install-cni.sh"]
17 changes: 0 additions & 17 deletions Dockerfile.arm64

This file was deleted.

9 changes: 5 additions & 4 deletions Dockerfile.openshift
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# This dockerfile is used for building for OpenShift
FROM registry.ci.openshift.org/openshift/release:golang-1.19 as builder
FROM --platform=$BUILDPLATFORM registry.ci.openshift.org/openshift/release:golang-1.19 as builder
ADD . /go/src/github.com/k8snetworkplumbingwg/whereabouts
WORKDIR /go/src/github.com/k8snetworkplumbingwg/whereabouts
ENV CGO_ENABLED=1
ENV CGO_ENABLED=0
ENV GO111MODULE=on
RUN go build -mod vendor -o bin/whereabouts cmd/whereabouts.go
RUN go build -mod vendor -o bin/ip-control-loop cmd/controlloop/controlloop.go
ARG TARGETARCH TARGETOS
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH go build -mod vendor -o bin/whereabouts cmd/whereabouts.go
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH go build -mod vendor -o bin/ip-control-loop cmd/controlloop/controlloop.go
WORKDIR /

FROM openshift/origin-base
Expand Down
1 change: 1 addition & 0 deletions hack/build-go.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ echo "VERSION: ${VERSION}"
echo "GIT_SHA: ${GIT_SHA}"
echo "GIT_TREE_STATE: ${GIT_TREE_STATE}"
echo "RELEASE_STATUS: ${RELEASE_STATUS}"
echo "PLATFORM: ${GOOS}/${GOARCH}"
VERSION_LDFLAGS="-X github.com/k8snetworkplumbingwg/whereabouts/pkg/version.Version=${VERSION} \
-X github.com/k8snetworkplumbingwg/whereabouts/pkg/version.GitSHA=${GIT_SHA} \
-X github.com/k8snetworkplumbingwg/whereabouts/pkg/version.GitTreeState=${GIT_TREE_STATE} \
Expand Down
2 changes: 1 addition & 1 deletion hack/e2e-setup-kind-cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ retry kubectl create -f "${CNIS_DAEMONSET_PATH}"
retry kubectl -n kube-system wait --for=condition=ready -l name="cni-plugins" pod --timeout=$TIMEOUT_K8
echo "## build whereabouts"
pushd "$ROOT"
$OCI_BIN build . -t "$IMG_NAME"
$OCI_BIN buildx build --load . -t "$IMG_NAME"
popd

echo "## load image into KinD"
Expand Down