Skip to content

Commit

Permalink
[PERFSCALE-2454]: Publish multi-arch container images (#34)
Browse files Browse the repository at this point in the history
This PR introduces a multi-arch build/publish approach

## Type of change

- [x] Refactor
- [x] New feature
- [ ] Bug fix
- [ ] Optimization
- [ ] Documentation Update

## Description

<!--- Describe your changes in detail -->

## Related Tickets & Documents

- Related Issue #
- Closes #

## Checklist before requesting a review

- [x] I have performed a self-review of my code.
- [ ] If it is a core feature, I have added thorough tests.

## Testing
- Please describe the System Under Test.
- Please provide detailed steps to perform tests related to this code
change:

```
krvoora # make docker-build
Building the container image
docker build --force-rm -f containers/Containerfile \
        -t quay.io/cloud-bulldozer/ingress-perf ./containers
[+] Building 1.4s (10/10) FINISHED                                                                                                                                                  
 => [internal] load .dockerignore                                                                                                                                              0.0s
 => => transferring context: 2B                                                                                                                                                0.0s
 => [internal] load build definition from Containerfile                                                                                                                        0.0s
 => => transferring dockerfile: 390B                                                                                                                                           0.0s
 => [internal] load metadata for registry.access.redhat.com/ubi8/ubi:latest                                                                                                    1.4s
 => [builder 1/2] FROM registry.access.redhat.com/ubi8/ubi:latest@sha256:2c05f0b15459fafd51807473c6d649db8cc1cfd0adf589495666d599ec79c61d                                      0.0s
 => [internal] load build context                                                                                                                                              0.0s
 => => transferring context: 30B                                                                                                                                               0.0s
 => CACHED [stage-1 2/4] RUN dnf install -y iproute procps-ng                                                                                                                  0.0s
 => CACHED [builder 2/2] RUN dnf install -y make git unzip gcc &&     git clone https://github.com/wg/wrk.git --depth=1 &&     cd wrk && make -j $(nproc)                      0.0s
 => CACHED [stage-1 3/4] COPY --from=builder /wrk/wrk /usr/bin/wrk                                                                                                             0.0s
 => CACHED [stage-1 4/4] COPY json.lua json.lua                                                                                                                                0.0s
 => exporting to image                                                                                                                                                         0.0s
 => => exporting layers                                                                                                                                                        0.0s
 => => writing image sha256:ae5da5544cec2f695649f1bc30e2c9fbb5d442554ad24c9d78c22bff92790582                                                                                   0.0s
 => => naming to quay.io/cloud-bulldozer/ingress-perf:latest                                                                                                                   0.0s
 krvoora #
```

- How were the fix/results from this change verified? Please provide
relevant screenshots or results.

---------

Signed-off-by: Krishna Harsha Voora <[email protected]>
Co-authored-by: Raúl Sevilla <[email protected]>
  • Loading branch information
krishvoor and rsevilla87 authored Sep 21, 2023
1 parent ae0e48a commit 1186865
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 2 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/build-container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Release ingress-netperf container image

on:
push:
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 }}
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

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.

0 comments on commit 1186865

Please sign in to comment.