Skip to content

Commit 062d54b

Browse files
committed
Updates Native build and runtime guides, Visual Studio 2022, UBI9
1 parent 0d554f2 commit 062d54b

File tree

2 files changed

+66
-43
lines changed

2 files changed

+66
-43
lines changed

docs/src/main/asciidoc/building-native-image.adoc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,16 @@ What does having a working C developer environment mean?
3939
sudo dnf install gcc glibc-devel zlib-devel libstdc++-static
4040
# Debian-based distributions:
4141
sudo apt-get install build-essential libz-dev zlib1g-dev
42+
# Arch Linux
43+
sudo pacman -S freetype2 gcc glibc lib32-gcc-libs zlib
4244
----
4345
* XCode provides the required dependencies on macOS:
4446
+
4547
[source,bash]
4648
----
4749
xcode-select --install
4850
----
49-
* On Windows, you will need to install the https://aka.ms/vs/15/release/vs_buildtools.exe[Visual Studio 2017 Visual C++ Build Tools]
51+
* On Windows, you will need to install the https://aka.ms/vs/17/release/vs_buildtools.exe[Visual Studio 2022 Visual C++ Build Tools]
5052
====
5153

5254
=== Background
@@ -220,7 +222,7 @@ Another solution is to write a script to do this for you:
220222
221223
[source,bash]
222224
----
223-
cmd /c 'call "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvars64.bat" && mvn package -Dnative'
225+
cmd /c 'call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" && mvn package -Dnative'
224226
----
225227
====
226228

docs/src/main/asciidoc/quarkus-runtime-base-image.adoc

Lines changed: 62 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -32,75 +32,74 @@ CMD ["./application", "-Dquarkus.http.host=0.0.0.0"]
3232
== Extending the image
3333

3434
Your application may have additional requirements.
35-
For example, if you have an application that requires `libfreetype.so`, you need to copy the native libraries to the container.
36-
In this case, you need to use a multi-stage `dockerfile` to copy the required libraries:
35+
For example, if you have an application that manipulates graphics, images, or PDFs, you likely have Quarkus AWT extension included in the project and your native executable will require some additional libraries to run.
36+
In this case, you need to use a multi-stage `dockerfile` to copy the required libraries.
3737

38-
[source, dockerfile]
39-
----
40-
# First stage - install the dependencies in an intermediate container
41-
FROM registry.access.redhat.com/ubi9/ubi-minimal:9.6 as BUILD
42-
RUN microdnf install freetype -y
43-
44-
# Second stage - copy the dependencies
45-
FROM quay.io/quarkus/ubi9-quarkus-micro-image:2.0
46-
COPY --from=BUILD \
47-
/lib64/libfreetype.so.6 \
48-
/lib64/libbz2.so.1 \
49-
/lib64/libpng16.so.16 \
50-
/lib64/
51-
52-
WORKDIR /work/
53-
COPY --chmod=0755 target/*-runner /work/application
54-
EXPOSE 8080
55-
CMD ["./application", "-Dquarkus.http.host=0.0.0.0"]
56-
----
38+
[WARNING]
39+
====
40+
Copying handpicked libraries makes up for a small container image, yet it is somewhat britte, differs for different base image versions, and it is a subject to change as transitive dependencies of these libraries might change.
41+
====
5742

58-
If you need to have access to the full AWT support, you need more than just `libfreetype.so`, but also the font and font configurations:
43+
[NOTE]
44+
====
45+
Headless graphics, PDF documents, QR code images etc. manipulation is natively supported on amd64/aarch64 Linux only. Neither Windows nor MacOS are supported and require running the application in a Linux container.
46+
====
5947

6048
[source, dockerfile]
6149
----
6250
# First stage - install the dependencies in an intermediate container
63-
FROM registry.access.redhat.com/ubi9/ubi-minimal:9.6 as BUILD
64-
RUN microdnf install freetype fontconfig -y
51+
FROM registry.access.redhat.com/ubi9/ubi-minimal:9.6 as nativelibs
52+
RUN microdnf install -y freetype fontconfig expat
6553
6654
# Second stage - copy the dependencies
6755
FROM quay.io/quarkus/ubi9-quarkus-micro-image:2.0
68-
COPY --from=BUILD \
56+
WORKDIR /work/
57+
COPY --from=nativelibs \
58+
/lib64/libz.so.1 \
59+
/lib64/libstdc++.so.6 \
6960
/lib64/libfreetype.so.6 \
7061
/lib64/libgcc_s.so.1 \
7162
/lib64/libbz2.so.1 \
7263
/lib64/libpng16.so.16 \
7364
/lib64/libm.so.6 \
74-
/lib64/libbz2.so.1 \
65+
/lib64/libexpat.so.1 \
7566
/lib64/libuuid.so.1 \
67+
/lib64/libxml2.so.2 \
68+
/lib64/libharfbuzz.so.0 \
69+
/lib64/libbrotlidec.so.1 \
70+
/lib64/libbrotlicommon.so.1 \
71+
/lib64/liblzma.so.5 \
72+
/lib64/libglib-2.0.so.0 \
73+
/lib64/libgraphite2.so.3 \
74+
/lib64/libpcre.so.1 \
7675
/lib64/
77-
78-
COPY --from=BUILD \
76+
COPY --from=nativelibs \
7977
/usr/lib64/libfontconfig.so.1 \
8078
/usr/lib64/
81-
82-
COPY --from=BUILD \
79+
COPY --from=nativelibs \
8380
/usr/share/fonts /usr/share/fonts
84-
85-
COPY --from=BUILD \
81+
COPY --from=nativelibs \
8682
/usr/share/fontconfig /usr/share/fontconfig
87-
88-
COPY --from=BUILD \
83+
COPY --from=nativelibs \
8984
/usr/lib/fontconfig /usr/lib/fontconfig
90-
91-
COPY --from=BUILD \
85+
COPY --from=nativelibs \
9286
/etc/fonts /etc/fonts
9387
94-
WORKDIR /work/
95-
COPY --chmod=0755 target/*-runner /work/application
88+
RUN chown 1001 /work \
89+
&& chmod "g+rwX" /work \
90+
&& chown 1001:root /work
91+
# Shared objects to be dynamically loaded at runtime as needed,
92+
COPY target/*.so /work/
93+
COPY --chown=1001:root --chmod=0755 target/*-runner /work/application
94+
9695
EXPOSE 8080
97-
CMD ["./application", "-Dquarkus.http.host=0.0.0.0"]
98-
----
96+
USER 1001
9997
98+
ENTRYPOINT ["./application", "-Dquarkus.http.host=0.0.0.0"]
99+
----
100100

101101
== Alternative - Using ubi-minimal
102102

103-
104103
If the micro image does not suit your requirements, you can use https://catalog.redhat.com/software/containers/ubi9-minimal/61832888c0d15aff4912fe0d[ubi9-minimal].
105104
It's a bigger image, but contains more utilities and is closer to a full Linux distribution.
106105
Typically, it contains a package manager (`microdnf`), so you can install packages more easily.
@@ -121,3 +120,25 @@ USER 1001
121120
122121
CMD ["./application", "-Dquarkus.http.host=0.0.0.0"]
123122
----
123+
124+
To make documents processing, graphics, PDFs, etc. available for the application, you can install the required libraries using `microdnf` without manually copying anything:
125+
126+
[source, dockerfile]
127+
----
128+
FROM registry.access.redhat.com/ubi9/ubi-minimal:9.6
129+
RUN microdnf install -y freetype fontconfig \
130+
&& microdnf clean all
131+
132+
WORKDIR /work/
133+
RUN chown 1001 /work \
134+
&& chmod "g+rwX" /work \
135+
&& chown 1001:root /work
136+
# Shared objects to be dynamically loaded at runtime as needed
137+
COPY --chown=1001:root target/*.so /work/
138+
COPY --chown=1001:root --chmod=0755 target/*-runner /work/application
139+
140+
EXPOSE 8080
141+
USER 1001
142+
143+
ENTRYPOINT ["./application", "-Dquarkus.http.host=0.0.0.0"]
144+
----

0 commit comments

Comments
 (0)