From 33d5c6007f28867da6051cb35133889094a1ec21 Mon Sep 17 00:00:00 2001 From: Iwauo Tajima Date: Tue, 22 Apr 2025 10:10:18 +0900 Subject: [PATCH] migrate to the spring base architecture. --- .dockerignore | 3 ++- Dockerfile | 10 ++++++++-- README.md | 2 +- entrypoint.sh | 15 +++++++++++++++ pom.xml | 37 +++++++++++++++++++++---------------- scripts/start.sh | 20 ++++++++++++++++---- 6 files changed, 63 insertions(+), 24 deletions(-) create mode 100755 entrypoint.sh diff --git a/.dockerignore b/.dockerignore index 01fe4bb..08b484c 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,3 @@ * -!/target/struts-cookbook.war +!/entrypoint.sh +!/target/extracted diff --git a/Dockerfile b/Dockerfile index 92dfddb..0601e13 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,9 @@ -FROM docker.io/tomcat:9.0.87-jre21-temurin-jammy -COPY target/struts-cookbook.war /usr/local/tomcat/webapps/ +FROM docker.io/azul/zulu-openjdk:21.0.1-21.30.15 +WORKDIR /app +COPY target/extracted/dependencies/ ./ +COPY target/extracted/spring-boot-loader/ ./ +COPY target/extracted/snapshot-dependencies/ ./ +COPY target/extracted/application/ ./ +COPY entrypoint.sh ./ +ENTRYPOINT ["./entrypoint.sh"] \ No newline at end of file diff --git a/README.md b/README.md index d90f55a..83aeee7 100755 --- a/README.md +++ b/README.md @@ -14,4 +14,4 @@ How to run - Open the following URL with your browser. -http://localhost:8080/struts-cookbook/ \ No newline at end of file +http://localhost:8080/ \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..8902b74 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +set -eu + +main() { + launch +} + +launch() { + java \ + ${DEBUG_PORT:+ -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:${DEBUG_PORT}} \ + "org.springframework.boot.loader.launch.WarLauncher" +} + +main \ No newline at end of file diff --git a/pom.xml b/pom.xml index 3105a69..2f178e4 100644 --- a/pom.xml +++ b/pom.xml @@ -25,23 +25,24 @@ war Struts Apps - Cookbook 1.0.0 - + + 21 + 21 + + + + local-repo + file:../mvn-repo + + - org.apache.struts - struts-taglib - 1.3.10 - - - javax.servlet - servlet-api - 2.3 - provided + io.github.iwauo.springing-struts + struts1-core + 0.0.5 - - ${project.artifactId} src/main/java @@ -52,10 +53,14 @@ - org.apache.maven.plugins - maven-war-plugin - 3.4.0 + org.springframework.boot + spring-boot-maven-plugin + + springing.struts1.entrypoint.Main + WAR + 3.2.5 + - + diff --git a/scripts/start.sh b/scripts/start.sh index a292f1c..0536584 100755 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -5,8 +5,8 @@ set -eu SCRIPT_DIR=$(realpath "$(dirname $BASH_SOURCE)") PROJECT_BASE_DIR=$(realpath "$SCRIPT_DIR/..") -APP_NAME=cookbook -CONTAINER_NAME=springing-struts1-$APP_NAME +APP_NAME=struts-cookbook +CONTAINER_NAME=springing-struts-$APP_NAME DOCKER=$( (command -v podman &> /dev/null) && echo podman || echo docker ) main() { @@ -14,12 +14,24 @@ main() { } build() { - mvn clean package -U + mvn \ + clean \ + dependency:purge-local-repository \ + -DreResolve=false \ + -DactTransitively=false \ + -DmanualInclude='io.github.iwauo.springing-struts' \ + package -U \ + spring-boot:repackage \ + && java \ + -Djarmode=layertools \ + -jar target/$APP_NAME-*.war \ + extract --destination target/extracted } start() { $DOCKER build -t $CONTAINER_NAME . \ - && $DOCKER rm -f $CONTAINER_NAME \ + && ($DOCKER stop -t 0 $CONTAINER_NAME || true) \ + && ($DOCKER rm -f $CONTAINER_NAME || true) \ && $DOCKER run -d \ -p 8080:8080 \ -p 5005:5005 \