From 10f5e9ff32239c186cac4fb875ff0da9a89102df Mon Sep 17 00:00:00 2001 From: Adarsh Date: Thu, 23 Jan 2025 07:56:34 +0000 Subject: [PATCH] Update java-spring-boot example Signed-off-by: Adarsh --- Examples/java-spring-boot/Dockerfile | 5 +--- Examples/java-spring-boot/README.md | 36 +++++++++++++--------------- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/Examples/java-spring-boot/Dockerfile b/Examples/java-spring-boot/Dockerfile index 30f09df2..b4c96a58 100644 --- a/Examples/java-spring-boot/Dockerfile +++ b/Examples/java-spring-boot/Dockerfile @@ -1,7 +1,4 @@ -FROM openjdk:11 - -RUN apt-get update && \ - apt-get install -y openjdk-11-jdk +FROM openjdk:21-jdk-slim COPY spring-boot-web-service/build/libs/spring-boot-web-service-0.0.1-SNAPSHOT.jar . diff --git a/Examples/java-spring-boot/README.md b/Examples/java-spring-boot/README.md index 6ed61599..d954956f 100644 --- a/Examples/java-spring-boot/README.md +++ b/Examples/java-spring-boot/README.md @@ -9,50 +9,48 @@ runs inside the SGX enclave. For more information on Spring Boot, please visit h * Tested on: - Type: Azure Confidential Computing SGX Virtual Machine - Size: Standard DC1s v3 (1 vCPU, 8 GiB memory) - - OS: Linux (Ubuntu 20.04) + - OS: Linux (Ubuntu 24.04) -* Install the OpenJDK 11 package so that Gradle can consume the files: +* Install the OpenJDK 21 package so that Gradle can consume the files: ```bash - $ sudo apt-get install openjdk-11-jdk + sudo apt-get install openjdk-21-jdk ``` -* Follow the installation guide at https://gradle.org/install/ to install Gradle v7.6. +* Follow the installation guide at https://gradle.org/install/ to install Gradle v8.12. ## Build and run graminized Docker image 1. Build a project using Gradle: ```bash -$ (cd spring-boot-web-service/ && gradle build) +(cd spring-boot-web-service/ && gradle build) ``` 2. Build Docker image: ```bash -$ docker build -t openjdk-11-java-spring-boot . +docker build -t openjdk-21-java-spring-boot . ``` 3. Clean up files that will be no longer used: ```bash -$ (cd spring-boot-web-service/ && gradle clean) +(cd spring-boot-web-service/ && gradle clean) ``` 4. Graminize the Docker image (this step can take some time!): ```bash -$ (cd ../.. && ./gsc build openjdk-11-java-spring-boot \ - Examples/java-spring-boot/java-spring-boot.manifest \ - -c ) +(cd ../.. && ./gsc build openjdk-21-java-spring-boot \ + Examples/java-spring-boot/java-spring-boot.manifest) ``` 5. Sign the graminized Docker image: ```bash -$ (cd ../.. && ./gsc sign-image openjdk-11-java-spring-boot \ - \ - -c ) +(cd ../.. && ./gsc sign-image openjdk-21-java-spring-boot \ + ) ``` 6. Run graminized image (the application may take a while to load): @@ -60,20 +58,20 @@ $ (cd ../.. && ./gsc sign-image openjdk-11-java-spring-boot \ * On the default port set to 8080: ```bash - $ docker run --rm --device=/dev/sgx_enclave \ + docker run --rm --device=/dev/sgx_enclave \ -v /var/run/aesmd/aesm.socket:/var/run/aesmd/aesm.socket \ -p 8080:8080 \ - -d gsc-openjdk-11-java-spring-boot + -d gsc-openjdk-21-java-spring-boot ``` * On a customized port using an environment variable, e.g. 9080: ```bash - $ docker run --rm --device=/dev/sgx_enclave \ + docker run --rm --device=/dev/sgx_enclave \ -v /var/run/aesmd/aesm.socket:/var/run/aesmd/aesm.socket \ -e SERVER_PORT=9080 \ -p 9080:9080 \ - -d gsc-openjdk-11-java-spring-boot + -d gsc-openjdk-21-java-spring-boot ``` @@ -82,11 +80,11 @@ $ (cd ../.. && ./gsc sign-image openjdk-11-java-spring-boot \ Boot application": ```bash -$ wget -qO- localhost: +wget -qO- localhost: ``` 8. To stop the graminized container with Spring-Boot application, run the command: ```bash -$ docker stop +docker stop ```