-
Notifications
You must be signed in to change notification settings - Fork 22
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
Add github actions to build and publish macvtap images. #125
Open
ashokpariya0
wants to merge
1
commit into
kubevirt:main
Choose a base branch
from
ashokpariya0:add-github-action-multiplatform
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: Push container image | ||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- 'v*.*.*' | ||
|
||
env: | ||
REGISTRY: quay.io | ||
IMAGE_NAME: kubevirt/macvtap-cni | ||
BUILD_PLATFORMS: linux/amd64,linux/arm64,linux/s390x | ||
|
||
jobs: | ||
build-and-push-image: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v4 | ||
|
||
# Add support for more platforms with QEMU (optional) | ||
# https://github.com/docker/setup-qemu-action | ||
- 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 | ||
if: github.repository_owner == 'kubevirt' | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build and push latest Macvtap container image | ||
if: github.repository_owner == 'kubevirt' | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: . | ||
push: true | ||
platforms: ${{ env.BUILD_PLATFORMS }} | ||
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest | ||
file: ./cmd/Dockerfile | ||
|
||
- name: Build and push tagged Macvtap container image | ||
if: startsWith(github.ref, 'refs/tags/') | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: . | ||
push: true | ||
platforms: ${{ env.BUILD_PLATFORMS }} | ||
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }} | ||
file: ./cmd/Dockerfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ go_sources=$(call rwildcard,cmd/,*.go) $(call rwildcard,pkg/,*.go) $(call rwildc | |
|
||
# Configure Go | ||
export GOOS=linux | ||
export GOARCH=amd64 | ||
export GOARCH=$(shell uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. due to https://github.com/kubevirt/macvtap-cni/pull/125/files#r1874637326 |
||
export CGO_ENABLED=0 | ||
export GO111MODULE=on | ||
export GOFLAGS=-mod=vendor | ||
|
@@ -69,7 +69,7 @@ vet: $(go_sources) $(GO) | |
$(GO) vet ./pkg/... ./cmd/... ./tests/... | ||
|
||
docker-build: | ||
$(OCI_BIN) build -t ${IMAGE_REGISTRY}/${IMAGE_NAME}:${IMAGE_TAG} -f ./cmd/Dockerfile . | ||
$(OCI_BIN) build --build-arg goarch=${GOARCH} -t ${IMAGE_REGISTRY}/${IMAGE_NAME}:${IMAGE_TAG} -f ./cmd/Dockerfile . | ||
|
||
docker-push: | ||
ifeq ($(OCI_BIN),podman) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,21 @@ | ||
# Multi-stage dockerfile building a container image with both binaries included | ||
|
||
FROM quay.io/projectquay/golang:1.20 as builder | ||
FROM --platform=$BUILDPLATFORM quay.io/projectquay/golang:1.20 AS builder | ||
ENV GOPATH=/go | ||
WORKDIR /go/src/github.com/kubevirt/macvtap-cni | ||
ARG goarch= | ||
ARG TARGETOS | ||
ARG TARGETARCH | ||
ENV TARGETOS=${TARGETOS:-linux} | ||
ENV TARGETARCH=${TARGETARCH:-amd64} | ||
|
||
ENV GOOS=${TARGETOS} | ||
ENV GOARCH=${goarch:-$TARGETARCH} | ||
|
||
COPY . . | ||
RUN GOOS=linux CGO_ENABLED=0 go build -o /macvtap-deviceplugin github.com/kubevirt/macvtap-cni/cmd/deviceplugin | ||
RUN GOOS=linux CGO_ENABLED=0 go build -o /macvtap-cni github.com/kubevirt/macvtap-cni/cmd/cni | ||
|
||
FROM registry.access.redhat.com/ubi8/ubi-minimal | ||
FROM --platform=linux/${TARGETARCH} registry.access.redhat.com/ubi8/ubi-minimal | ||
COPY --from=builder /macvtap-deviceplugin /macvtap-deviceplugin | ||
COPY --from=builder /macvtap-cni /macvtap-cni |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please dont add this file
we need to change this prow job instead, after the PR is merged
https://prow.ci.kubevirt.io/view/gs/kubevirt-prow/logs/publish-macvtap-cni/1839203924632932352
a follow-up effort (or maybe pre refactor)
might be good indeed to use git actions instead, but this is up to Miguel decision
note please that if we are doing that, we will need of course to align project-infra, this repo, and CNAO
as CNAO consumes the images, this why imho it better be orthogonal follow-up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @oshoval, I see that the above Prow job uses the script publish.sh to build and push the macvtap CNI image, and it uses the make command. Are you suggesting that we can add multi-platform support(like we added for cnao nad other cnis) by make command and adding export PLATFORMS=all in publish.sh as a follow-up to the PR? This way, we would have two options: we can either continue using the Prow job here to build and publish the image, or we can switch to using GitHub Actions for the same purpose.
cc @maiqueb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
personally i prefer to add the "all" and stick to prow atm,
switching to git actions require changes on more repos and personally won't have time to focus on that
it can be done as follow-up when time comes, but better not rush it please
thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay sure, I will raise new PR with multi support enabled using make commands so that it can be easily work with existing prow job.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can even add the "all" in this PR imo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@oshoval I created a new PR: #127 to enable multi-platform builds using the make command. This change ensures compatibility with the existing Prow jobs that handle the build and push of release images. I will add the GitHub Actions changes in a follow-up PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
Please drop the git actions, it is not good to have both atm, and not required
imo we can have just one PR which is 125 + 127 without git actions for now
later on we can consider to move to git actions, but not now please