You can now generate a native plantuml binary with vanilla GraalVM and PlantUML commands
mikaelhg opened this issue · 4 comments
mikaelhg commented
docker run -it --rm -w /data -v $PWD/data:/data --entrypoint=/bin/bash \
ghcr.io/graalvm/graalvm-ce:22.2.0
gu install native-image
microdnf install freetype freetype-devel graphviz diffutils && microdnf clean all
curl -L -o plantuml-1.2022.6.jar https://github.com/plantuml/plantuml/releases/download/v1.2022.6/plantuml-1.2022.6.jar
curl -L -o jlatexmath-1.0.7.jar https://repo1.maven.org/maven2/org/scilab/forge/jlatexmath/1.0.7/jlatexmath-1.0.7.jar
git clone https://github.com/coni2k/PlantUML.git examples
java -agentlib:native-image-agent=config-output-dir=conf/META-INF/native-image \
-cp jlatexmath-1.0.7.jar:plantuml-1.2022.6.jar \
net.sourceforge.plantuml.Run \
-headless -o out-java ./examples/*/*.puml
native-image --auto-fallback --enable-http --enable-https \
--report-unsupported-elements-at-runtime \
-H:Name=plantuml-1.2022.6-glibc-x86_64 \
-H:IncludeResources="stdlib/.*repx" \
-H:IncludeResources="net/sourceforge/plantuml.*(png|svg|txt)$" \
-cp jlatexmath-1.0.7.jar:plantuml-1.2022.6.jar:./conf \
net.sourceforge.plantuml.Run
./plantuml-1.2022.6-glibc-x86_64 -headless -o out-native examples/*/*.puml
mikaelhg commented
This produces a 75 MB binary, which can be further reduced to 27 MB with the upx
binary packer.
mikaelhg commented
If you want to run the glibc binary on Alpine, you need to:
apk add gcompat libstdc++ fontconfig ttf-dejavu ttf-liberation
mikaelhg commented
The puml files processed in the configuration generation phase should cover as many of the PlantUML features as possible, so that the configuration files contain everything necessary. The repo https://github.com/coni2k/PlantUML seems to be good for this.