Imagen de tiempo de ejecución de Quarkus Base
To ease the containerization of native executables, Quarkus provides a base image providing the requirements to run these executables.
The ubi9-quarkus-micro-image:2.0
image is:
-
small (based on
ubi9-micro
) -
diseñado para contenedores
-
contiene el conjunto correcto de dependencias (glibc, libstdc++, zlib)
-
soportar los ejecutables comprimidos por upx (más detalles en la documentación sobre la habilitación de la compresión)
Uso de la imagen base
En su Dockerfile
, sólo tiene que utilizar:
FROM quay.io/quarkus/ubi9-quarkus-micro-image:2.0
WORKDIR /work/
COPY --chmod=0755 target/*-runner /work/application
EXPOSE 8080
CMD ["./application", "-Dquarkus.http.host=0.0.0.0"]
Ampliación de la imagen
Your application may have additional requirements.
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.
In this case, you need to use a multi-stage dockerfile
to copy the required libraries.
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. |
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. |
# First stage - install the dependencies in an intermediate container
FROM registry.access.redhat.com/ubi9/ubi-minimal:9.6 as nativelibs
RUN microdnf install -y freetype fontconfig expat
# Second stage - copy the dependencies
FROM quay.io/quarkus/ubi9-quarkus-micro-image:2.0
WORKDIR /work/
COPY --from=nativelibs \
/lib64/libz.so.1 \
/lib64/libstdc++.so.6 \
/lib64/libfreetype.so.6 \
/lib64/libgcc_s.so.1 \
/lib64/libbz2.so.1 \
/lib64/libpng16.so.16 \
/lib64/libm.so.6 \
/lib64/libexpat.so.1 \
/lib64/libuuid.so.1 \
/lib64/libxml2.so.2 \
/lib64/libharfbuzz.so.0 \
/lib64/libbrotlidec.so.1 \
/lib64/libbrotlicommon.so.1 \
/lib64/liblzma.so.5 \
/lib64/libglib-2.0.so.0 \
/lib64/libgraphite2.so.3 \
/lib64/libpcre.so.1 \
/lib64/
COPY --from=nativelibs \
/usr/lib64/libfontconfig.so.1 \
/usr/lib64/
COPY --from=nativelibs \
/usr/share/fonts /usr/share/fonts
COPY --from=nativelibs \
/usr/share/fontconfig /usr/share/fontconfig
COPY --from=nativelibs \
/usr/lib/fontconfig /usr/lib/fontconfig
COPY --from=nativelibs \
/etc/fonts /etc/fonts
RUN chown 1001 /work \
&& chmod "g+rwX" /work \
&& chown 1001:root /work
# Shared objects to be dynamically loaded at runtime as needed,
COPY target/*.so /work/
COPY --chown=1001:root --chmod=0755 target/*-runner /work/application
EXPOSE 8080
USER 1001
ENTRYPOINT ["./application", "-Dquarkus.http.host=0.0.0.0"]
Alternativa - Uso de ubi-minimal
If the micro image does not suit your requirements, you can use ubi9-minimal.
It’s a bigger image, but contains more utilities and is closer to a full Linux distribution.
Typically, it contains a package manager (microdnf
), so you can install packages more easily.
Para utilizar esta imagen de base, utilice la siguiente dirección Dockerfile
:
FROM registry.access.redhat.com/ubi9/ubi-minimal:9.6
WORKDIR /work/
RUN chown 1001 /work \
&& chmod "g+rwX" /work \
&& chown 1001:root /work
COPY --chown=1001:root --chmod=0755 target/*-runner /work/application
EXPOSE 8080
USER 1001
CMD ["./application", "-Dquarkus.http.host=0.0.0.0"]
To make documents processing, graphics, PDFs, etc. available for the application, you can install the required libraries using microdnf
without manually copying anything:
FROM registry.access.redhat.com/ubi9/ubi-minimal:9.6
RUN microdnf install -y freetype fontconfig \
&& microdnf clean all
WORKDIR /work/
RUN chown 1001 /work \
&& chmod "g+rwX" /work \
&& chown 1001:root /work
# Shared objects to be dynamically loaded at runtime as needed
COPY --chown=1001:root target/*.so /work/
COPY --chown=1001:root --chmod=0755 target/*-runner /work/application
EXPOSE 8080
USER 1001
ENTRYPOINT ["./application", "-Dquarkus.http.host=0.0.0.0"]