Skip to content

Commit 4081abc

Browse files
committed
X-Smart-Squash: Squashed 19 commits:
4829124 Add arm64 build and test images 591a0a4 matrix f308f72 format 2bd6ed1 arm runners c874046 include 029d72f failfastfalse d088cd2 arch tags c02366d create multiarch manifest 254e179 space 782ab48 handle 5432a37 fix 14f0332 target 2cfd390 flip 48f9992 amd64 01eddcb push arch 9a6b3ff quotes 407c401 update 4e30669 - 5e4456d flav
1 parent 7869112 commit 4081abc

File tree

7 files changed

+224
-74
lines changed

7 files changed

+224
-74
lines changed

.github/actions/build-and-push-image/action.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@ inputs:
44
image-flavor:
55
description: A flavor used to tag the apollo-ci image.
66
required: true
7+
arch:
8+
description: Arch for image build (amd64 or arm64)
9+
required: true
710
runs:
811
using: composite
912
steps:
10-
- name: Build and push image
13+
- name: Build and push x86_64 image
1114
run: |
1215
.github/actions/build-and-push-image/build-and-push-image.sh \
13-
"${{ inputs.image-flavor }}"
16+
"${{ inputs.image-flavor }}" "${{ inputs.arch }}"
1417
shell: bash

.github/actions/build-and-push-image/build-and-push-image.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,21 @@ set -euo pipefail
44

55
build_and_push_image() {
66
local image_flavor="$1"
7+
local target_arch="$2"
8+
local tag_suffix="-${target_arch}"
9+
10+
if [ -z $target_arch ]; then
11+
target_arch="amd64"
12+
tag_suffix=""
13+
fi
714

815
# Login may be required for pulling the base image for building (if used) and to avoid rate limits.
916
docker login -u "$QUAY_RHACS_ENG_RW_USERNAME" --password-stdin <<<"$QUAY_RHACS_ENG_RW_PASSWORD" quay.io
1017

11-
TAG="$(scripts/get_tag.sh "$image_flavor")"
18+
TAG="$(scripts/get_tag.sh "$image_flavor")${tag_suffix}"
1219
IMAGE="quay.io/rhacs-eng/apollo-ci:${TAG}"
1320

14-
make "$image_flavor"-image
21+
make TARGETARCH="$target_arch" "$image_flavor"-image
1522

1623
retry 5 true docker push "${IMAGE}"
1724

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Create and push a multiarch manifest
2+
description: |
3+
This action will create a multiarch manifest and push it to a remote registry.
4+
5+
inputs:
6+
base-image:
7+
description:
8+
The base image to used for the manifest
9+
required: true
10+
image-flavor:
11+
description:
12+
The image flavor tag to be used for the manifest
13+
required: true
14+
suffix:
15+
description:
16+
Optional suffix for the tags used and the manifest
17+
default: ''
18+
archs:
19+
description:
20+
Architectures to be included in the final manifest, separated by a space
21+
default: 'amd64 arm64'
22+
runs:
23+
using: composite
24+
steps:
25+
- shell: bash
26+
run: |
27+
image_flavor="${{ inputs.image-flavor }}"
28+
tag="$(scripts/get_tag.sh ${image_flavor})"
29+
read -ra archs <<< "${{ inputs.archs }}"
30+
declare -a images=()
31+
for arch in "${archs[@]}"; do
32+
images+=("${{ inputs.base-image }}:${tag}-${arch}${{ inputs.suffix }}")
33+
done
34+
35+
docker manifest create "${{ inputs.base-image }}:${tag}${{ inputs.suffix }}" "${images[@]}"
36+
docker manifest push "${{ inputs.base-image }}:${tag}${{ inputs.suffix }}"
37+

.github/workflows/build.yaml

Lines changed: 67 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,15 @@ env:
1818
jobs:
1919

2020
build-and-push-stackrox-build:
21-
runs-on: ubuntu-latest
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
include:
25+
- arch: amd64
26+
runner: ubuntu-24.04
27+
- arch: arm64
28+
runner: ubuntu-24.04-arm
29+
runs-on: ${{ matrix.runner }}
2230
steps:
2331
- name: Checkout
2432
uses: actions/checkout@v3
@@ -28,9 +36,18 @@ jobs:
2836
- uses: ./.github/actions/build-and-push-image
2937
with:
3038
image-flavor: "stackrox-build"
39+
arch: ${{ matrix.arch }}
3140

3241
build-and-push-stackrox-test:
33-
runs-on: ubuntu-latest
42+
strategy:
43+
fail-fast: false
44+
matrix:
45+
include:
46+
- arch: amd64
47+
runner: ubuntu-24.04
48+
- arch: arm64
49+
runner: ubuntu-24.04-arm
50+
runs-on: ${{ matrix.runner }}
3451
needs:
3552
- build-and-push-stackrox-build
3653
steps:
@@ -42,7 +59,54 @@ jobs:
4259
- uses: ./.github/actions/build-and-push-image
4360
with:
4461
image-flavor: "stackrox-test"
45-
62+
arch: ${{ matrix.arch }}
63+
64+
build-and-push-multiarch:
65+
runs-on: ubuntu-latest
66+
needs:
67+
- build-and-push-stackrox-build
68+
- build-and-push-stackrox-test
69+
steps:
70+
- name: Checkout
71+
uses: actions/checkout@v3
72+
with:
73+
fetch-depth: 0
74+
ref: ${{ github.event.pull_request.head.sha }}
75+
76+
- name: Login to quay.io/stackrox-io
77+
uses: docker/login-action@v3
78+
with:
79+
registry: quay.io
80+
username: ${{ secrets.QUAY_STACKROX_IO_RW_USERNAME }}
81+
password: ${{ secrets.QUAY_STACKROX_IO_RW_PASSWORD }}
82+
83+
- uses: ./.github/actions/create-multiarch-manifest
84+
with:
85+
base-image: quay.io/stackrox-io/apollo-ci
86+
image-flavor: stackrox-build
87+
88+
- uses: ./.github/actions/create-multiarch-manifest
89+
with:
90+
base-image: quay.io/stackrox-io/apollo-ci
91+
image-flavor: stackrox-test
92+
93+
- name: Login to quay.io/rhacs-eng
94+
uses: docker/login-action@v3
95+
with:
96+
registry: quay.io
97+
username: ${{ secrets.QUAY_RHACS_ENG_RW_USERNAME }}
98+
password: ${{ secrets.QUAY_RHACS_ENG_RW_PASSWORD }}
99+
100+
- uses: ./.github/actions/create-multiarch-manifest
101+
with:
102+
base-image: quay.io/rhacs-eng/apollo-ci
103+
image-flavor: stackrox-build
104+
105+
- uses: ./.github/actions/create-multiarch-manifest
106+
with:
107+
base-image: quay.io/rhacs-eng/apollo-ci
108+
image-flavor: stackrox-test
109+
46110
build-and-push-stackrox-ui-test:
47111
runs-on: ubuntu-latest
48112
steps:

Makefile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ endif
44
QUAY_REPO=rhacs-eng
55

66
STACKROX_BUILD_TAG=$(shell scripts/get_tag.sh "stackrox-build")
7+
TARGETARCH?=amd64
78

89
.PHONY: stackrox-build-image
910
stackrox-build-image:
1011
$(DOCKER) build \
11-
--platform linux/amd64 \
12+
--platform linux/$(TARGETARCH) \
1213
-t quay.io/$(QUAY_REPO)/apollo-ci:$(STACKROX_BUILD_TAG) \
14+
-t quay.io/$(QUAY_REPO)/apollo-ci:$(STACKROX_BUILD_TAG)-$(TARGETARCH) \
1315
-f images/stackrox-build.Dockerfile \
1416
images/
1517

@@ -18,9 +20,10 @@ STACKROX_TEST_TAG=$(shell scripts/get_tag.sh "stackrox-test")
1820
.PHONY: stackrox-test-image
1921
stackrox-test-image:
2022
$(DOCKER) build \
21-
--platform linux/amd64 \
23+
--platform linux/$(TARGETARCH) \
2224
-t quay.io/$(QUAY_REPO)/apollo-ci:$(STACKROX_TEST_TAG) \
23-
--build-arg BASE_TAG=$(STACKROX_BUILD_TAG) \
25+
-t quay.io/$(QUAY_REPO)/apollo-ci:$(STACKROX_TEST_TAG)-$(TARGETARCH) \
26+
--build-arg BASE_TAG=$(STACKROX_BUILD_TAG)-$(TARGETARCH) \
2427
-f images/stackrox-test.Dockerfile \
2528
images/
2629

@@ -40,7 +43,7 @@ test-cci-export:
4043
$(DOCKER) build \
4144
--platform linux/amd64 \
4245
-t test-cci-export \
43-
--build-arg BASE_TAG=$(STACKROX_TEST_TAG) \
46+
--build-arg BASE_TAG=$(STACKROX_TEST_TAG)-amd64 \
4447
-f images/test.cci-export.Dockerfile \
4548
images/
4649
$(DOCKER) run \

images/stackrox-build.Dockerfile

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,31 +55,41 @@ RUN dnf update -y && \
5555
dnf clean all && \
5656
rm -rf /var/cache/dnf /var/cache/yum
5757

58+
ENV GOPATH=/go
59+
ENV PATH=$GOPATH/bin:/usr/local/go/bin:$PATH
5860
ARG GOLANG_VERSION=1.23.6
59-
ARG GOLANG_SHA256=9379441ea310de000f33a4dc767bd966e72ab2826270e038e78b2c53c2e7802d
60-
ENV GOPATH /go
61-
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
62-
RUN url="https://dl.google.com/go/go${GOLANG_VERSION}.linux-amd64.tar.gz" && \
63-
wget --no-verbose -O go.tgz "$url" && \
61+
RUN set -e; case "$(uname -m)" in \
62+
"x86_64" ) GOLANG_ARCH="amd64" GOLANG_SHA256="9379441ea310de000f33a4dc767bd966e72ab2826270e038e78b2c53c2e7802d";; \
63+
"aarch64") GOLANG_ARCH="arm64" GOLANG_SHA256="561c780e8f4a8955d32bf72e46af0b5ee5e0debe1e4633df9a03781878219202";; \
64+
*) echo "Unsupported $(uname -m)"; exit 1;; \
65+
esac && \
66+
wget --no-verbose -O go.tgz "https://dl.google.com/go/go${GOLANG_VERSION}.linux-${GOLANG_ARCH}.tar.gz" && \
6467
echo "${GOLANG_SHA256} *go.tgz" | sha256sum -c - && \
6568
tar -C /usr/local -xzf go.tgz && \
6669
rm go.tgz && \
6770
mkdir -p "$GOPATH/src" "$GOPATH/bin" && \
6871
chmod -R 777 "$GOPATH"
6972

70-
ARG FETCH_VERSION=0.3.5
71-
ARG FETCH_SHA256=8d4d99e903b30dbd24290e9a056a982ea2326a05ded24c63be64df16e7e0d9f0
72-
RUN wget --no-verbose -O fetch https://github.com/gruntwork-io/fetch/releases/download/v${FETCH_VERSION}/fetch_linux_amd64 && \
73+
ARG FETCH_VERSION=0.4.6
74+
RUN set -e; case "$(uname -m)" in \
75+
"x86_64" ) FETCH_ARCH="amd64" FETCH_SHA256="a67ed3141d6deb7e7841f40505cba11eb7a37abbab78374712a42373e7854209";; \
76+
"aarch64") FETCH_ARCH="arm64" FETCH_SHA256="4b9115a1f1a90c7088bff9ffc7d2de3547ef1d21709528e878af09a4c348dea3";; \
77+
*) echo "Unsupported $(uname -m)"; exit 1;; \
78+
esac && \
79+
wget --no-verbose -O fetch https://github.com/gruntwork-io/fetch/releases/download/v${FETCH_VERSION}/fetch_linux_${FETCH_ARCH} && \
7380
echo "${FETCH_SHA256} fetch" | sha256sum -c - && \
7481
install fetch /usr/bin && \
7582
rm fetch
7683

7784
ARG OSSLS_VERSION=0.11.1
78-
ARG OSSLS_SHA256=f1bf3012961c1d90ba307a46263f29025028d35c209b9a65e5c7d502c470c95f
79-
RUN fetch --repo="https://github.com/stackrox/ossls" --tag="${OSSLS_VERSION}" --release-asset="ossls_linux_amd64" . && \
80-
echo "${OSSLS_SHA256} *ossls_linux_amd64" | sha256sum -c - && \
81-
install ossls_linux_amd64 /usr/bin/ossls && \
82-
rm ossls_linux_amd64 && \
85+
RUN set -e; case "$(uname -m)" in \
86+
"x86_64" ) OSSLS_ARCH="amd64" OSSLS_SHA256="f1bf3012961c1d90ba307a46263f29025028d35c209b9a65e5c7d502c470c95f";; \
87+
*) echo "Unsupported $(uname -m), skipping."; exit 0;; \
88+
esac && \
89+
fetch --repo="https://github.com/stackrox/ossls" --tag="${OSSLS_VERSION}" --release-asset="ossls_linux_${OSSLS_ARCH}" . && \
90+
echo "${OSSLS_SHA256} *ossls_linux_${OSSLS_ARCH}" | sha256sum -c - && \
91+
install ossls_linux_${OSSLS_ARCH} /usr/bin/ossls && \
92+
rm ossls_linux_${OSSLS_ARCH} && \
8393
ossls version
8494

8595
ENV CGO_ENABLED=1

0 commit comments

Comments
 (0)