diff --git a/.github/workflows/image-push-master.yaml b/.github/workflows/image-push-master.yaml index 7f3192f..74e9a05 100644 --- a/.github/workflows/image-push-master.yaml +++ b/.github/workflows/image-push-master.yaml @@ -2,71 +2,16 @@ name: "push images on merge to master" env: IMAGE_NAME: ghcr.io/${{ github.repository }} + PLATFORMS: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x on: push: branches: - master -jobs: - build-and-push-amd64-ib-sriov-cni: - name: image push amd64 - runs-on: ubuntu-24.04 - steps: - - name: check out the repo - uses: actions/checkout@v5 - - - name: set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: login to Docker - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: build and push ib-sriov-cni - uses: docker/build-push-action@v6 - with: - context: . - push: true - platforms: linux/amd64 - tags: | - ${{ env.IMAGE_NAME }}:latest-amd64 - file: ./Dockerfile - - build-and-push-arm64-ib-sriov-cni: - name: image push arm64 - runs-on: ubuntu-24.04 - steps: - - name: check out the repo - uses: actions/checkout@v5 - - - name: set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: login to Docker - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: build and push ib-sriov-cni - uses: docker/build-push-action@v6 - with: - context: . - push: true - platforms: linux/arm64 - tags: | - ${{ env.IMAGE_NAME }}:latest-arm64 - file: ./Dockerfile - - build-and-push-ppc64le-ib-sriov-cni: - name: image Push ppc64le +jobs: + build-and-push-ib-sriov-cni: + name: build and push multi-arch image (Master) runs-on: ubuntu-24.04 steps: - name: check out the repo @@ -85,33 +30,13 @@ jobs: username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - - name: build and push ib-sriov-cni + - name: build and push ib-sriov-cni (multi-arch) uses: docker/build-push-action@v6 with: context: . push: true - platforms: linux/ppc64le + platforms: ${{ env.PLATFORMS }} tags: | - ${{ env.IMAGE_NAME }}:latest-ppc64le + ${{ env.IMAGE_NAME }}:latest file: ./Dockerfile - push-manifest: - runs-on: ubuntu-24.04 - needs: [build-and-push-amd64-ib-sriov-cni,build-and-push-arm64-ib-sriov-cni,build-and-push-ppc64le-ib-sriov-cni] - steps: - - name: set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: login to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Create manifest for multi-arch images - run: | - docker buildx imagetools create -t ${{ env.IMAGE_NAME }}:latest -t ${{ env.IMAGE_NAME }}:${{ github.sha }} \ - ${{ env.IMAGE_NAME }}:latest-amd64 \ - ${{ env.IMAGE_NAME }}:latest-arm64 \ - ${{ env.IMAGE_NAME }}:latest-ppc64le diff --git a/.github/workflows/image-push-release.yaml b/.github/workflows/image-push-release.yaml index 37dd0cb..20cc806 100644 --- a/.github/workflows/image-push-release.yaml +++ b/.github/workflows/image-push-release.yaml @@ -2,89 +2,17 @@ name: "push images on release" env: IMAGE_NAME: ghcr.io/${{ github.repository }} + PLATFORMS: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x on: push: tags: - v* -jobs: - build-and-push-amd64-ib-sriov-cni: - runs-on: ubuntu-24.04 - name: image push AMD64 - steps: - - name: check out the repo - uses: actions/checkout@v5 - - - name: set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: login to Docker - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: docker meta - id: docker_meta - uses: docker/metadata-action@v5 - with: - images: ${{ env.IMAGE_NAME }} - flavor: | - latest=false - tags: | - type=ref,event=tag - - - name: build and push ib-sriov-cni - uses: docker/build-push-action@v6 - with: - context: . - push: true - platforms: linux/amd64 - tags: | - ${{ steps.docker_meta.outputs.tags }}-amd64 - file: ./Dockerfile - build-and-push-arm64-ib-sriov-cni: - runs-on: ubuntu-24.04 - name: image push ARM64 - steps: - - name: check out the repo - uses: actions/checkout@v5 - - - name: set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: login to Docker - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: docker meta - id: docker_meta - uses: docker/metadata-action@v5 - with: - images: ${{ env.IMAGE_NAME }} - flavor: | - latest=false - tags: | - type=ref,event=tag - - - name: build and push ib-sriov-cni - uses: docker/build-push-action@v6 - with: - context: . - push: true - platforms: linux/arm64 - tags: | - ${{ steps.docker_meta.outputs.tags }}-arm64 - file: ./Dockerfile - - build-and-push-ppc64le-ib-sriov-cni: +jobs: + build-and-push-ib-sriov-cni: runs-on: ubuntu-24.04 - name: image push ppc64le + name: build and push multi-arch image (Release) steps: - name: check out the repo uses: actions/checkout@v5 @@ -109,43 +37,12 @@ jobs: tags: | type=ref,event=tag - - name: build and push ib-sriov-cni + - name: build and push ib-sriov-cni (multi-arch) uses: docker/build-push-action@v6 with: context: . push: true - platforms: linux/arm64 + platforms: ${{ env.PLATFORMS }} tags: | - ${{ steps.docker_meta.outputs.tags }}-ppc64le + ${{ steps.docker_meta.outputs.tags }} file: ./Dockerfile - - push-manifest: - runs-on: ubuntu-24.04 - needs: [build-and-push-amd64-ib-sriov-cni,build-and-push-arm64-ib-sriov-cni,build-and-push-ppc64le-ib-sriov-cni] - steps: - - name: set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: docker meta - id: docker_meta - uses: docker/metadata-action@v5 - with: - images: ${{ env.IMAGE_NAME }} - flavor: | - latest=false - tags: | - type=ref,event=tag - - - name: login to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: create manifest for multi-arch images - run: | - docker buildx imagetools create -t ${{ steps.docker_meta.outputs.tags }} \ - ${{ steps.docker_meta.outputs.tags }}-amd64 \ - ${{ steps.docker_meta.outputs.tags }}-arm64 \ - ${{ steps.docker_meta.outputs.tags }}-ppc64le diff --git a/Dockerfile b/Dockerfile index 43609fd..58117d4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,16 @@ -FROM golang:1.24-alpine as builder +FROM golang:1.24-alpine AS builder COPY . /usr/src/ib-sriov-cni -ENV HTTP_PROXY $http_proxy -ENV HTTPS_PROXY $https_proxy +ARG TARGETOS +ARG TARGETARCH +ARG http_proxy +ARG https_proxy + +ENV HTTP_PROXY=$http_proxy \ + HTTPS_PROXY=$https_proxy \ + GOOS=$TARGETOS \ + GOARCH=$TARGETARCH RUN apk add --no-cache --virtual build-dependencies build-base=~0.5 WORKDIR /usr/src/ib-sriov-cni