diff --git a/native-image/spring-boot-webserver/Dockerfile.alpine.static b/native-image/spring-boot-webserver/Dockerfile.alpine.static index f3423f6..5bdc0ed 100644 --- a/native-image/spring-boot-webserver/Dockerfile.alpine.static +++ b/native-image/spring-boot-webserver/Dockerfile.alpine.static @@ -2,7 +2,7 @@ FROM container-registry.oracle.com/graalvm/native-image:24-muslib AS nativebuild COPY . /webserver WORKDIR /webserver # Build a fully static native image with optimization for size -RUN ./mvnw -Dmaven.test.skip=true -Pnative,fully-static native:compile +RUN ./mvnw -Dmaven.test.skip=true -Pnative,static native:compile # Alpine - no glibc FROM alpine:3 diff --git a/native-image/spring-boot-webserver/Dockerfile.scratch.static b/native-image/spring-boot-webserver/Dockerfile.scratch.static index 7fb8ab2..d1b6553 100644 --- a/native-image/spring-boot-webserver/Dockerfile.scratch.static +++ b/native-image/spring-boot-webserver/Dockerfile.scratch.static @@ -2,7 +2,7 @@ FROM container-registry.oracle.com/graalvm/native-image:24-muslib AS nativebuild COPY . /webserver WORKDIR /webserver # Build a fully static native image with optimization for size -RUN ./mvnw -Dmaven.test.skip=true -Pnative,fully-static native:compile +RUN ./mvnw -Dmaven.test.skip=true -Pnative,static native:compile # Scratch-nothing FROM scratch diff --git a/native-image/spring-boot-webserver/Dockerfile.scratch.static-upx b/native-image/spring-boot-webserver/Dockerfile.scratch.static-upx index 1405a95..eecb3fd 100644 --- a/native-image/spring-boot-webserver/Dockerfile.scratch.static-upx +++ b/native-image/spring-boot-webserver/Dockerfile.scratch.static-upx @@ -13,7 +13,7 @@ RUN microdnf -y install wget xz && \ rm -rf upx-${UPX_VERSION}-amd64_linux # Build a fully static native image with optimization for size -RUN ./mvnw -Dmaven.test.skip=true -Pnative,fully-static native:compile +RUN ./mvnw -Dmaven.test.skip=true -Pnative,static native:compile RUN ls -lh /webserver/target # Compress with UPX RUN ./upx --lzma --best -o /webserver/webserver.static-upx /webserver/target/webserver.static diff --git a/native-image/spring-boot-webserver/README.md b/native-image/spring-boot-webserver/README.md index 0c3e4a0..a618214 100644 --- a/native-image/spring-boot-webserver/README.md +++ b/native-image/spring-boot-webserver/README.md @@ -41,7 +41,7 @@ cd native-image/spring-boot-webserver Unzip the static resources required for the application: ```bash -unzip src/main/resources/static.zip -d src/main/resources/static +unzip src/main/resources/static.zip -d src/main/resources ``` ## **STEP 1**: Compile and Run the Application from a JAR File Inside a Container @@ -92,7 +92,7 @@ Jlink, or `jlink`, is a tool that generates a custom Java runtime image that con This is one of the approaches to make applications more space efficient and cloud-friendly, introduced in Java 11. The script _build-jlink.sh_ that runs `docker build` using the _Dockerfile.distroless-java-base.jlink_. -The Dockerfile runs two stages: first it generates a Jlink custom runtime on a full JDK (`container-registry.oracle.com/graalvm/jdk:24`); then copies the runtime image folder along with static website pages into a Distroless Java base image, and sets the entrypoint. +The Dockerfile runs two stages: first it generates a Jlink custom runtime on a full JDK (`container-registry.oracle.com/graalvm/jdk:24`); then copies the runtime image folder along with static website pages into a distroless Java base image, and sets the entrypoint. Distroless Java base image provides `glibc` and other libraries needed by the JDK, but not a full-blown JDK. The application does not have to be modular, but you need to figure out which modules the application depends on to be able to `jlink` it. @@ -493,7 +493,7 @@ A _scratch_ container is a [Docker official image](https://hub.docker.com/_/scra A separate Maven profile exists for this step: ```xml - fully-static + static diff --git a/native-image/spring-boot-webserver/build-alpine-static-image.sh b/native-image/spring-boot-webserver/build-alpine-static-image.sh index 981f4b3..4b24444 100755 --- a/native-image/spring-boot-webserver/build-alpine-static-image.sh +++ b/native-image/spring-boot-webserver/build-alpine-static-image.sh @@ -6,6 +6,6 @@ # TOOLCHAIN_DIR=${SCRIPT_DIR}/musl-toolchain # PATH=${TOOLCHAIN_DIR}/bin:${PATH} -# ./mvnw -Dmaven.test.skip=true -Pnative,fully-static native:compile +# ./mvnw -Dmaven.test.skip=true -Pnative,static native:compile docker build --no-cache . -f Dockerfile.alpine.static -t webserver:scratch.static-alpine \ No newline at end of file diff --git a/native-image/spring-boot-webserver/build-static-image.sh b/native-image/spring-boot-webserver/build-static-image.sh index be93a55..d97f4b7 100755 --- a/native-image/spring-boot-webserver/build-static-image.sh +++ b/native-image/spring-boot-webserver/build-static-image.sh @@ -6,7 +6,7 @@ # TOOLCHAIN_DIR=${SCRIPT_DIR}/musl-toolchain # PATH=${TOOLCHAIN_DIR}/bin:${PATH} -# ./mvnw -Dmaven.test.skip=true -Pnative,fully-static native:compile +# ./mvnw -Dmaven.test.skip=true -Pnative,static native:compile # Scratch-nothing docker build --no-cache . -f Dockerfile.scratch.static -t webserver:scratch.static \ No newline at end of file diff --git a/native-image/spring-boot-webserver/pom.xml b/native-image/spring-boot-webserver/pom.xml index 7927121..e276a0a 100644 --- a/native-image/spring-boot-webserver/pom.xml +++ b/native-image/spring-boot-webserver/pom.xml @@ -146,7 +146,7 @@ - fully-static + static diff --git a/native-image/spring-boot-webserver/src/main/resources/static.zip b/native-image/spring-boot-webserver/src/main/resources/static.zip index c4d0ba7..51567ef 100644 Binary files a/native-image/spring-boot-webserver/src/main/resources/static.zip and b/native-image/spring-boot-webserver/src/main/resources/static.zip differ