Skip to content

Commit faed48d

Browse files
committed
Creating docker images with native builds
1 parent 1e382f1 commit faed48d

4 files changed

Lines changed: 69 additions & 11 deletions

File tree

.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
*
2-
!target/*-runner
2+
!target/*-runner-*
33
!target/*-runner.jar
44
!target/lib/*
55
!target/quarkus-app/*

.github/workflows/build.yml

Lines changed: 58 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- name: Build
2828
run: make build
2929

30-
- name: Upload artifact
30+
- name: Upload artifact [target]
3131
uses: actions/upload-artifact@v4
3232
with:
3333
name: target
@@ -57,15 +57,22 @@ jobs:
5757
- name: Set up Docker Buildx
5858
uses: docker/setup-buildx-action@v3
5959

60-
- name: Download artifact
60+
- name: Download artifact [target]
6161
uses: actions/download-artifact@v4
6262
with:
6363
name: target
6464
path: target
6565

66+
- name: Build and push [jvm-edge]
67+
run: docker buildx build --push -t ghcr.io/javabin/submittheforce:jvm-edge -f src/main/docker/Dockerfile.jvm --platform linux/amd64,linux/arm64 .
68+
6669
- name: Build and push [edge]
6770
run: docker buildx build --push -t ghcr.io/javabin/submittheforce:edge -f src/main/docker/Dockerfile.jvm --platform linux/amd64,linux/arm64 .
6871

72+
- name: Build and push [jvm-latest]
73+
if: startsWith(github.ref, 'refs/tags/v')
74+
run: docker buildx build --push -t ghcr.io/javabin/submittheforce:jvm-latest -f src/main/docker/Dockerfile.jvm --platform linux/amd64,linux/arm64 .
75+
6976
- name: Build and push [latest]
7077
if: startsWith(github.ref, 'refs/tags/v')
7178
run: docker buildx build --push -t ghcr.io/javabin/submittheforce:latest -f src/main/docker/Dockerfile.jvm --platform linux/amd64,linux/arm64 .
@@ -90,7 +97,7 @@ jobs:
9097
- name: Build uber-JAR
9198
run: make build build-uber
9299

93-
- name: Upload artifact
100+
- name: Upload artifact [uber-jar]
94101
uses: actions/upload-artifact@v4
95102
with:
96103
name: uber-jar
@@ -123,7 +130,7 @@ jobs:
123130
- name: Set up Docker Buildx
124131
uses: docker/setup-buildx-action@v3
125132

126-
- name: Download artifact
133+
- name: Download artifact [target]
127134
uses: actions/download-artifact@v4
128135
with:
129136
name: target
@@ -135,7 +142,7 @@ jobs:
135142
- name: Rename file
136143
run: mv target/submit-runner target/submit-runner-linux-x86_64
137144

138-
- name: Upload artifact
145+
- name: Upload artifact [native-amd64]
139146
uses: actions/upload-artifact@v4
140147
with:
141148
name: native-amd64
@@ -147,7 +154,7 @@ jobs:
147154
if: startsWith(github.ref, 'refs/tags/v')
148155
with:
149156
token: ${{ secrets.GITHUB_TOKEN }}
150-
file: target/submit-runner-linux-amd64
157+
file: target/submit-runner-linux-x86_64
151158
name: submit-runner-linux-amd64
152159
label: Native [amd64]
153160

@@ -167,7 +174,7 @@ jobs:
167174
- name: Set up Docker Buildx
168175
uses: docker/setup-buildx-action@v3
169176

170-
- name: Download artifact
177+
- name: Download artifact [target]
171178
uses: actions/download-artifact@v4
172179
with:
173180
name: target
@@ -179,7 +186,7 @@ jobs:
179186
- name: Rename file
180187
run: mv target/submit-runner target/submit-runner-linux-aarch64
181188

182-
- name: Upload artifact
189+
- name: Upload artifact [native-arm64]
183190
uses: actions/upload-artifact@v4
184191
with:
185192
name: native-arm64
@@ -194,3 +201,46 @@ jobs:
194201
file: target/submit-runner-linux-aarch64
195202
name: submit-runner-linux-aarch64
196203
label: Native [arm64]
204+
205+
docker-native:
206+
name: Docker [Native]
207+
runs-on: ubuntu-latest
208+
needs:
209+
- native-amd64
210+
- native-arm64
211+
212+
steps:
213+
- name: Checkout
214+
uses: actions/checkout@v4
215+
216+
- name: Login to GitHub Container Registry
217+
uses: docker/login-action@v3
218+
with:
219+
registry: ghcr.io
220+
username: ${{ github.actor }}
221+
password: ${{ secrets.GITHUB_TOKEN }}
222+
223+
- name: Set up QEMU
224+
uses: docker/setup-qemu-action@v3
225+
226+
- name: Set up Docker Buildx
227+
uses: docker/setup-buildx-action@v3
228+
229+
- name: Download artifact [native-amd64]
230+
uses: actions/download-artifact@v4
231+
with:
232+
name: native-arm64
233+
path: target
234+
235+
- name: Download artifact [native-amd64]
236+
uses: actions/download-artifact@v4
237+
with:
238+
name: native-amd64
239+
path: target
240+
241+
- name: Build and push [native-edge]
242+
run: docker buildx build --push -t ghcr.io/javabin/submittheforce:native-edge -f src/main/docker/Dockerfile.jvm --platform linux/amd64,linux/arm64 .
243+
244+
- name: Build and push [native-latest]
245+
if: startsWith(github.ref, 'refs/tags/v')
246+
run: docker buildx build --push -t ghcr.io/javabin/submittheforce:native-latest -f src/main/docker/Dockerfile.jvm --platform linux/amd64,linux/arm64 .

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ build-uber:
55
@./mvnw package -B --no-transfer-progress package -Dquarkus.package.jar.type=uber-jar
66

77
native:
8-
@./mvnw package -Dnative -Dquarkus.native.container-build=true
8+
@./mvnw package -B --no-transfer-progress -Dnative -Dquarkus.native.container-build=true
99

1010
clean:
1111
@./mvnw clean -B --no-transfer-progress

src/main/docker/Dockerfile.native-micro

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# Adding fetch stage to build the native image for multiple architectures
2+
FROM alpine AS fetch
3+
4+
ADD target /target
5+
RUN mv /target/*-runner-linux-$(uname -m) /target/application
6+
17
####
28
# This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode.
39
# It uses a micro base image, tuned for Quarkus native executables.
@@ -22,7 +28,9 @@ WORKDIR /work/
2228
RUN chown 1001 /work \
2329
&& chmod "g+rwX" /work \
2430
&& chown 1001:root /work
25-
COPY --chown=1001:root target/*-runner /work/application
31+
32+
# Modified to use the fetch stage
33+
COPY --from=fetch --chown=1001:root /target/application /work/application
2634

2735
EXPOSE 8080
2836
USER 1001

0 commit comments

Comments
 (0)