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
67 changes: 67 additions & 0 deletions .github/workflows/build-container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
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/Containerfile' # Trigger only when Dockerfile changes in a pull request
krishvoor marked this conversation as resolved.
Show resolved Hide resolved

env:
CONTAINER_REGISTRY: ${{ github.repository_owner == 'cloud-bulldozer' && 'quay.io' }}
RHEL_VERSION: ubi9
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-arch Image
id: push
uses: docker/build-push-action@v3
with:
file: containers/Dockerfile
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x
tags: ${{ steps.meta.outputs.tags }}
push: ${{ github.event_name != 'pull_request' }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
RHEL_VERSION=${{ env.RHEL_VERSION }}
GO_VER=${{ env.GO_VER }}
GO_TAGS=
krishvoor marked this conversation as resolved.
Show resolved Hide resolved
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
DOCKER_BUILD ?= docker build --force-rm
krishvoor marked this conversation as resolved.
Show resolved Hide resolved
DOCKER_NS ?= quay.io/cloud-bulldozer
GIT_COMMIT = $(shell git rev-parse HEAD)

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

.PHONY: build lint clean

all: lint build
all: lint build docker-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

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

clean:
rm -Rf $(BIN_DIR)

Expand Down
6 changes: 3 additions & 3 deletions assets/Containerfile → containers/Containerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM registry.access.redhat.com/ubi8/ubi:latest as builder
RUN dnf install -y make git unzip gcc
RUN git clone https://github.com/wg/wrk.git --depth=1
RUN cd wrk && make -j $(nproc)
RUN dnf install -y make git unzip gcc && \
krishvoor marked this conversation as resolved.
Show resolved Hide resolved
git clone https://github.com/wg/wrk.git --depth=1 && \
cd wrk && make -j $(nproc)

FROM registry.access.redhat.com/ubi8/ubi:latest
RUN dnf install -y iproute procps-ng
Expand Down
File renamed without changes.
Loading