-
Notifications
You must be signed in to change notification settings - Fork 13
131 lines (127 loc) · 6 KB
/
multi-arch-images.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
---
name: Multi-Arch Images Test
on:
push:
branches: [ "multi-arch-images" ]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
arch:
- amd64
- arm64
permissions:
contents: read
packages: write
name: Build Docker Images for ${{ matrix.arch }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
cache: maven
- name: Set Image Tag
run: |
echo "BUILD_IMAGE_TAG=${GITHUB_REF_NAME}-${GITHUB_SHA}" >> $GITHUB_ENV
echo "CONTAINER_REGISTRY=ghcr.io" >> $GITHUB_ENV
echo "CONTAINER_GROUP=ozangunalp" >> $GITHUB_ENV
- name: Set up QEMU
if: matrix.arch == 'arm64'
uses: docker/setup-qemu-action@v3
with:
platforms: ${{ matrix.arch }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
install: true
- name: Build with Maven
run: |
mvn -s .github/ci-maven-settings.xml -B clean package \
${{ matrix.arch == 'arm64' && '-Dnative -Dquarkus.native.additional-build-args=-H:PageSize=65536' || '-Dnative' }} \
-Dquarkus.container-image.registry=${{ env.CONTAINER_REGISTRY }} \
-Dquarkus.container-image.group=${{ env.CONTAINER_GROUP }} \
-Dquarkus.native.container-build=true \
-Dquarkus.native.container-runtime-options=--platform=linux/${{ matrix.arch }} \
-Dquarkus.docker.buildx.platform=linux/${{ matrix.arch }} \
-Dquarkus.container-image.build=true \
-Dquarkus.container-image.push=false \
-Dquarkus.container-image.tag=${{ env.BUILD_IMAGE_TAG }}-${{ matrix.arch }} \
-Dquarkus.container-image.additional-tags=latest-snapshot-${{ matrix.arch }}
- name: Inspect Image
run: docker inspect ${{ env.CONTAINER_REGISTRY }}/${{ env.CONTAINER_GROUP }}/kafka-native:${{ env.BUILD_IMAGE_TAG }}-${{ matrix.arch }}
- name: Integration Tests with Maven
run: |
mvn -s .github/ci-maven-settings.xml -B clean verify -Dtest-container \
-Dkafka-native-container-image=${{ env.CONTAINER_REGISTRY }}/${{ env.CONTAINER_GROUP }}/kafka-native \
-Dkafka-native-container-version=${{ env.BUILD_IMAGE_TAG }}-${{ matrix.arch }} \
-Dzookeeper-native-container-image=${{ env.CONTAINER_REGISTRY }}/${{ env.CONTAINER_GROUP }}/zookeeper-native \
-Dzookeeper-native-container-version=${{ env.BUILD_IMAGE_TAG }}-${{ matrix.arch }}
- name: Save kafka-native image ${{ matrix.arch }}
uses: ishworkh/[email protected]
with:
image: "${{ env.CONTAINER_REGISTRY }}/${{ env.CONTAINER_GROUP }}/kafka-native:${{ env.BUILD_IMAGE_TAG }}-${{ matrix.arch }}"
- name: Save zookeeper-native image ${{ matrix.arch }}
uses: ishworkh/[email protected]
with:
image: "${{ env.CONTAINER_REGISTRY }}/${{ env.CONTAINER_GROUP }}/zookeeper-native:${{ env.BUILD_IMAGE_TAG }}-${{ matrix.arch }}"
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.CONTAINER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push kafka-native images
working-directory: ${{ matrix.project.name }}
run: "docker push -a ${{ env.CONTAINER_REGISTRY }}/${{ env.CONTAINER_GROUP }}/kafka-native"
- name: Push zookeeper-native images
working-directory: ${{ matrix.project.name }}
run: "docker push -a ${{ env.CONTAINER_REGISTRY }}/${{ env.CONTAINER_GROUP }}/zookeeper-native"
create-multiarch-manifest:
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
container:
- kafka-native
- zookeeper-native
permissions:
contents: read
packages: write
name: Create Multiarch Docker Images for ${{ matrix.container }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
cache: maven
- name: Set Image Tag
run: |
echo "BUILD_IMAGE_TAG=${GITHUB_REF_NAME}-${GITHUB_SHA}" >> $GITHUB_ENV
echo "CONTAINER_REGISTRY=ghcr.io" >> $GITHUB_ENV
echo "CONTAINER_GROUP=ozangunalp" >> $GITHUB_ENV
echo "ADDITIONAL_TAG=latest-snapshot" >> $GITHUB_ENV
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.CONTAINER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create and push multi-arch manifests ${{ matrix.container }}
shell: bash
run: |
docker manifest create ${{ env.CONTAINER_REGISTRY }}/${{ env.CONTAINER_GROUP }}/${{ matrix.container }}:${{ env.BUILD_IMAGE_TAG }} \
-a ${{ env.CONTAINER_REGISTRY }}/${{ env.CONTAINER_GROUP }}/${{ matrix.container }}:${{ env.BUILD_IMAGE_TAG }}-amd64 \
-a ${{ env.CONTAINER_REGISTRY }}/${{ env.CONTAINER_GROUP }}/${{ matrix.container }}:${{ env.BUILD_IMAGE_TAG }}-arm64
docker manifest push ${{ env.CONTAINER_REGISTRY }}/${{ env.CONTAINER_GROUP }}/${{ matrix.container }}:${{ env.BUILD_IMAGE_TAG }}
docker manifest create ${{ env.CONTAINER_REGISTRY }}/${{ env.CONTAINER_GROUP }}/${{ matrix.container }}:${{ env.ADDITIONAL_TAG }} \
-a ${{ env.CONTAINER_REGISTRY }}/${{ env.CONTAINER_GROUP }}/${{ matrix.container }}:${{ env.ADDITIONAL_TAG }}-amd64 \
-a ${{ env.CONTAINER_REGISTRY }}/${{ env.CONTAINER_GROUP }}/${{ matrix.container }}:${{ env.ADDITIONAL_TAG }}-arm64
docker manifest push ${{ env.CONTAINER_REGISTRY }}/${{ env.CONTAINER_GROUP }}/${{ matrix.container }}:${{ env.ADDITIONAL_TAG }}