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

[PERFSCALE-2454]: Publish multi-arch container images #34

Merged
merged 12 commits into from
Sep 21, 2023
61 changes: 61 additions & 0 deletions .github/workflows/build-container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Release ingress-netperf container image

on:
pull_request:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We must trigger this workflow on a push event. Doing it on a pull_request event is dangerous, as any PR would trigger a container build and can introduce incorrect or malicious code.

Copy link
Member Author

@krishvoor krishvoor Sep 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack, will change from pull_request

paths:
- 'containers/**' # Trigger only when Dockerfile changes in a pull request

env:
CONTAINER_REGISTRY: ${{ github.repository_owner == 'cloud-bulldozer' && 'quay.io' }}
GO_VER: 1.19

jobs:

build-and-push-container-images:
name: Build and Push Container Images
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

steps:
- name: Setup QEMU
uses: docker/setup-qemu-action@v2

- name: Setup docker-buildx
uses: docker/setup-buildx-action@v2
with:
buildkitd-flags: --debug
config-inline: |
[worker.oci]
max-parallelism = 1
krishvoor marked this conversation as resolved.
Show resolved Hide resolved

- name: Checkout
uses: actions/checkout@v3

- name: Login to the ${{ env.CONTAINER_REGISTRY }} Container Registry
uses: docker/login-action@v2
with:
registry: ${{ env.CONTAINER_REGISTRY }}
username: ${{ env.CONTAINER_REGISTRY == 'quay.io' && secrets.QUAY_USER || github.actor }}
password: ${{ env.CONTAINER_REGISTRY == 'quay.io' && secrets.QUAY_TOKEN || secrets.GITHUB_TOKEN }

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.CONTAINER_REGISTRY }}/${{ github.repository_owner }}/netperf
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}.{{minor}}.{{patch}}
krishvoor marked this conversation as resolved.
Show resolved Hide resolved

- name: Build and Push Multi archiecture Image
id: push
run: |
make gha-build
make push
env:
GO_VER=${{ env.GO_VER }}
GO_TAGS=
20 changes: 18 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
CONTAINER_BUILD ?= podman build --force-rm
CONTAINER_NS ?= quay.io/cloud-bulldozer
GIT_COMMIT = $(shell git rev-parse HEAD)

BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
Expand All @@ -18,16 +20,30 @@ CGO = 0

.PHONY: build lint clean

all: lint build
all: lint build container-build

build: $(BIN_PATH)

$(BIN_PATH): $(SOURCES)
GOARCH=$(shell go env GOARCH) CGO_ENABLED=$(CGO) go build -v -ldflags "-X $(INGRESS_PERF_VERSION).GitCommit=$(GIT_COMMIT) -X $(INGRESS_PERF_VERSION).Version=$(VERSION) -X $(INGRESS_PERF_VERSION).BuildDate=$(BUILD_DATE)" -o $(BIN_PATH) cmd/ingress-perf.go

container-build: build
@echo "Building the container image"
$(CONTAINER_BUILD) -f containers/Containerfile \
-t $(CONTAINER_NS)/$(BIN_NAME) ./containers

gha-build: build
@echo "Building Multi-architecture container Images"
$(CONTAINER_BUILD) -f containers/Containerfile \
--platform=linux/amd64,linux/arm64,linux/ppc64le,linux/s390x \
-t $(CONTAINER_NS)/$(BIN_NAME) ./containers --manifest=$(CONTAINER_NS)/$(BIN_NAME):latest
krishvoor marked this conversation as resolved.
Show resolved Hide resolved

gha-push: gha-build
@echo "Pushing Container Images"
$(CONTAINER_BUILD) manifest push

clean:
rm -Rf $(BIN_DIR)

lint:
golangci-lint run

File renamed without changes.
File renamed without changes.
Loading