|
| 1 | +# script to measure the sizes (and size savings) |
| 2 | + |
| 3 | +S2I=${S2I-s2i} |
| 4 | +ENGINE=${ENGINE-docker} # or e.g. podman |
| 5 | +BASEIMG=registry.access.redhat.com/ubi9/openjdk-17:latest |
| 6 | +APPSRC=https://github.com/quarkusio/quarkus-quickstarts |
| 7 | +CONTEXTDIR=getting-started |
| 8 | +rev=3.6.6 |
| 9 | +OUTIMG=out-s2i-image |
| 10 | + |
| 11 | +# first build the image using shipped builder images |
| 12 | +$S2I build --pull-policy never \ |
| 13 | + -e MAVEN_S2I_ARTIFACT_DIRS=target \ |
| 14 | + -e S2I_SOURCE_DEPLOYMENTS_FILTER="*.jar quarkus-app" \ |
| 15 | + -e QUARKUS_PACKAGE_TYPE=uber-jar \ |
| 16 | + -e MAVEN_CLEAR_REPO=true \ |
| 17 | + -e JAVA_APP_JAR=getting-started-1.0.0-SNAPSHOT-runner.jar \ |
| 18 | + --context-dir=$CONTEXTDIR -r=${rev} \ |
| 19 | + $APPSRC \ |
| 20 | + $BASEIMG \ |
| 21 | + $OUTIMG |
| 22 | + |
| 23 | +echo "baseline (simple S2I output):" |
| 24 | +${ENGINE} inspect -f '{{.Size}}' $OUTIMG |
| 25 | + |
| 26 | +# second, do a build with the image from jlink-dev branch |
| 27 | +# make sure it's been built! |
| 28 | +# NOTE: we override most variables from .s2i/environment in the quickstart |
| 29 | +# sources below, in order to an uber-jar. |
| 30 | +BASEIMG=ubi9/openjdk-17:latest |
| 31 | +OUTIMG=ubi9-jlinked-image # matches input in templates/jlink/Dockerfile |
| 32 | + |
| 33 | +$S2I build --pull-policy never \ |
| 34 | + -e S2I_ENABLE_JLINK=true \ |
| 35 | + -e MAVEN_S2I_ARTIFACT_DIRS=target \ |
| 36 | + -e S2I_SOURCE_DEPLOYMENTS_FILTER="*.jar quarkus-app" \ |
| 37 | + -e QUARKUS_PACKAGE_TYPE=uber-jar \ |
| 38 | + -e JAVA_APP_JAR=getting-started-1.0.0-SNAPSHOT-runner.jar \ |
| 39 | + --context-dir=$CONTEXTDIR -r=${rev} \ |
| 40 | + $APPSRC \ |
| 41 | + $BASEIMG \ |
| 42 | + $OUTIMG |
| 43 | + |
| 44 | +echo "intermediate jlink image size:" |
| 45 | +docker inspect -f '{{.Size}}' $OUTIMG |
| 46 | + |
| 47 | +# third, run the above thru the second-stage process |
| 48 | +OUTIMG=jlink-final |
| 49 | +${ENGINE} build -t "$OUTIMG" templates/jlink |
| 50 | +echo "final jlinked image size:" |
| 51 | +docker inspect -f '{{.Size}}' "$OUTIMG" |
0 commit comments