The English version of quarkus.io is the official project site. Translated sites are community supported on a best-effort basis.
このページを編集

Quarkusベースランタイムイメージ

ネイティブ実行可能ファイルのコンテナ化を容易にするため、Quarkusでは、実行可能ファイルを実行するための要件を提供するベースイメージを用意しています。 ubi9-quarkus-micro-image:2.0 イメージは以下の特徴を持ちます:

  • 小さい ( ubi9-micro に基づく)

  • コンテナ用に設計

  • 正しい依存関係のセット(glibc, libstdc++, zlib)を含んでいる

  • upx圧縮された実行可能ファイルのサポート(詳細は 圧縮の有効化についてのドキュメントを参照してください)

ベースイメージの利用

Dockerfile の中で以下を記述します:

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"]

イメージの拡張

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"]

代替 - ubi-minimalを使用する

マイクロイメージがあなたの要件に合わない場合、ubi 9 -minimal を使うことができます。 これはより大きなイメージですが、より多くのユーティリティを含み、完全な Linux ディストリビューションに近いものです。典型的には、パッケージマネージャ ( microdnf ) が含まれているので、より簡単にパッケージをインストールできます。

このベースイメージを使用するには、以下の 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"]

関連コンテンツ