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
53 changes: 53 additions & 0 deletions .github/workflows/build-container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
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: ${{ 'quay.io' }}
GO_VER: 1.19

jobs:
build-and-publish-container-images:
name: Build and Publish Multi Architecture Container Images
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

steps:
- name: Setup QEMU & Install Dependecies
run: |
sudo apt-get update -y
sudo apt-get install qemu-user-static fuse-overlayfs -y
sudo apt-get install podman -y
if: runner.os == 'Linux'

- name: Clone Repository
uses: actions/checkout@v3

- name: Setup Golang
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VER }}

- name: Verify Go Version
run: go version

- name: Login to the ${{ env.CONTAINER_REGISTRY }} Container Registry
run: podman login quay.io -u ${QUAY_USER} -p ${QUAY_TOKEN}
env:
QUAY_USER: ${{ secrets.QUAY_USER }}
QUAY_TOKEN: ${{ secrets.QUAY_TOKEN }}

- name: Build and Push Multi archiecture Image
id: push
run: |
make gha-build
make gha-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