Skip to content

Commit 6622a50

Browse files
Copilotalexandru
andcommitted
Implement parallel Docker image builds for JVM and Native
Co-authored-by: alexandru <11753+alexandru@users.noreply.github.com>
1 parent 51a5db3 commit 6622a50

2 files changed

Lines changed: 101 additions & 8 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 72 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,18 @@ on:
33
workflow_dispatch:
44

55
jobs:
6-
deploy_docker_jvm:
7-
runs-on: ubuntu-22.04
6+
build_jvm_matrix:
7+
strategy:
8+
matrix:
9+
include:
10+
- platform: linux/amd64
11+
runner: ubuntu-24.04
12+
- platform: linux/arm64
13+
runner: ubuntu-24.04-arm
14+
runs-on: ${{ matrix.runner }}
15+
permissions:
16+
contents: read
17+
packages: write
818
steps:
919
- uses: actions/checkout@v4
1020

@@ -18,14 +28,46 @@ jobs:
1828
username: ${{ github.actor }}
1929
password: ${{ secrets.GITHUB_TOKEN }}
2030

21-
- name: Build and Push JVM Docker images
31+
- name: Build and Push JVM Docker image for ${{ matrix.platform }}
2232
run: |
23-
make push-jvm
33+
make push-jvm-platform PLATFORM=${{ matrix.platform }}
2434
env:
2535
GIT_TAG: ${{ github.ref }}
2636

27-
deploy_docker_native:
37+
create_jvm_manifest:
38+
needs: build_jvm_matrix
2839
runs-on: ubuntu-22.04
40+
permissions:
41+
contents: read
42+
packages: write
43+
steps:
44+
- uses: actions/checkout@v4
45+
46+
- name: Login to GitHub Container Registry
47+
uses: docker/login-action@v3
48+
with:
49+
registry: ghcr.io
50+
username: ${{ github.actor }}
51+
password: ${{ secrets.GITHUB_TOKEN }}
52+
53+
- name: Create and Push JVM multi-platform manifest
54+
run: |
55+
make push-jvm-manifest
56+
env:
57+
GIT_TAG: ${{ github.ref }}
58+
59+
build_native_matrix:
60+
strategy:
61+
matrix:
62+
include:
63+
- platform: linux/amd64
64+
runner: ubuntu-24.04
65+
- platform: linux/arm64
66+
runner: ubuntu-24.04-arm
67+
runs-on: ${{ matrix.runner }}
68+
permissions:
69+
contents: read
70+
packages: write
2971
steps:
3072
- uses: actions/checkout@v4
3173

@@ -39,16 +81,38 @@ jobs:
3981
username: ${{ github.actor }}
4082
password: ${{ secrets.GITHUB_TOKEN }}
4183

42-
- name: Build and Push Native Docker images
84+
- name: Build and Push Native Docker image for ${{ matrix.platform }}
85+
run: |
86+
make push-native-platform PLATFORM=${{ matrix.platform }}
87+
env:
88+
GIT_TAG: ${{ github.ref }}
89+
90+
create_native_manifest:
91+
needs: build_native_matrix
92+
runs-on: ubuntu-22.04
93+
permissions:
94+
contents: read
95+
packages: write
96+
steps:
97+
- uses: actions/checkout@v4
98+
99+
- name: Login to GitHub Container Registry
100+
uses: docker/login-action@v3
101+
with:
102+
registry: ghcr.io
103+
username: ${{ github.actor }}
104+
password: ${{ secrets.GITHUB_TOKEN }}
105+
106+
- name: Create and Push Native multi-platform manifest
43107
run: |
44-
make push-native
108+
make push-native-manifest
45109
env:
46110
GIT_TAG: ${{ github.ref }}
47111

48112
all:
49113
name: Pushed All
50114
if: always()
51-
needs: [ deploy_docker_native, deploy_docker_jvm ]
115+
needs: [ create_jvm_manifest, create_native_manifest ]
52116
runs-on: ubuntu-22.04
53117
steps:
54118
- name: Validate required tests

Makefile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ IMG_NATIVE := ${NAME}:native-${TAG}
55
LATEST_JVM := ${NAME}:jvm-latest
66
LATEST_NATIVE := ${NAME}:native-latest
77
LATEST := ${NAME}:latest
8+
PLATFORM ?= linux/amd64,linux/arm64
89

910
dependency-updates:
1011
./gradlew dependencyUpdates \
@@ -23,6 +24,20 @@ build-jvm: init-docker
2324
push-jvm:
2425
DOCKER_EXTRA_ARGS="--push" $(MAKE) build-jvm
2526

27+
# Build and push for a single platform (used in matrix builds)
28+
build-jvm-platform: init-docker
29+
$(eval PLATFORM_TAG := $(shell echo ${PLATFORM} | tr '/' '-'))
30+
docker buildx build --platform ${PLATFORM} -f ./src/main/docker/Dockerfile.jvm -t "${IMG_JVM}-${PLATFORM_TAG}" -t "${LATEST_JVM}-${PLATFORM_TAG}" ${DOCKER_EXTRA_ARGS} .
31+
32+
push-jvm-platform:
33+
DOCKER_EXTRA_ARGS="--push" $(MAKE) build-jvm-platform
34+
35+
# Create and push multi-platform manifest combining platform-specific images
36+
push-jvm-manifest:
37+
docker buildx imagetools create -t "${IMG_JVM}" -t "${LATEST_JVM}" \
38+
"${IMG_JVM}-linux-amd64" \
39+
"${IMG_JVM}-linux-arm64"
40+
2641
build-jvm-local:
2742
docker build -f ./src/main/docker/Dockerfile.jvm -t "${IMG_JVM}" -t "${LATEST_JVM}" .
2843

@@ -35,6 +50,20 @@ build-native: init-docker
3550
push-native:
3651
DOCKER_EXTRA_ARGS="--push" $(MAKE) build-native
3752

53+
# Build and push for a single platform (used in matrix builds)
54+
build-native-platform: init-docker
55+
$(eval PLATFORM_TAG := $(shell echo ${PLATFORM} | tr '/' '-'))
56+
docker buildx build --platform ${PLATFORM} -f ./src/main/docker/Dockerfile.native -t "${IMG_NATIVE}-${PLATFORM_TAG}" -t "${LATEST_NATIVE}-${PLATFORM_TAG}" -t "${LATEST}-${PLATFORM_TAG}" ${DOCKER_EXTRA_ARGS} .
57+
58+
push-native-platform:
59+
DOCKER_EXTRA_ARGS="--push" $(MAKE) build-native-platform
60+
61+
# Create and push multi-platform manifest combining platform-specific images
62+
push-native-manifest:
63+
docker buildx imagetools create -t "${IMG_NATIVE}" -t "${LATEST_NATIVE}" -t "${LATEST}" \
64+
"${IMG_NATIVE}-linux-amd64" \
65+
"${IMG_NATIVE}-linux-arm64"
66+
3867
build-native-local:
3968
docker build -f ./src/main/docker/Dockerfile.native -t "${IMG_NATIVE}" -t "${LATEST_NATIVE}" -t "${LATEST}" .
4069

0 commit comments

Comments
 (0)