Upx
Ultimate Packer for eXecutables (UPX)は、実行ファイルのサイズを小さくする圧縮ツールです。Quarkusでは、生成されたネイティブ実行可能ファイルを圧縮して、そのサイズを小さくすることができます。このような圧縮は次のような場合に興味深いものです。
-
CLIツールをビルドする場合。ディスクのフットプリントを減らすことが望まれます。
-
小さなコンテナイメージをビルドする場合。
なお、UPX圧縮は
-
主に高圧縮レベルを使用した場合、ビルド時間が長くなります。
-
アプリケーションの起動時のRSS使用量が増加します。
システムvs.コンテナ
UPX圧縮には、以下のような条件があります。
-
the
upx
command to be available in the systemPATH
; -
or to have built the native executable using an in-container build.
If you have the upx
command available on your path, Quarkus uses it. Otherwise, if you built the native image using an in-container build (using quarkus.native.container-build=true
) and if the builder image provides the upx
command, Quarkus compresses the executable from inside the container.
If you are not in one of these cases, the compression fails.
upxはクロスプラットフォームです。
|
UPX圧縮の設定
Then, in your application configuration, enable the compression by configuring the compression level you want:
quarkus.native.compression.level=5
If the compression level is not set, the compression is disabled. The compression will happen once the native executable is built and will replace the executable.
追加パラメータ
You can pass extra parameter to upx, such as --brute
or --ultra-brute
using the quarkus.native.compression.additional-args
parameter. The value is a comma-separated list of arguments:
quarkus.native.compression.level=3
quarkus.native.compression.additional-args=--ultra-brute,-v
The exhaustive list of parameters can be found in the UPX documentation.