Skip to content

migrate to the spring base architecture. #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*
!/target/struts-cookbook.war
!/entrypoint.sh
!/target/extracted
10 changes: 8 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ How to run

- Open the following URL with your browser.

http://localhost:8080/struts-cookbook/
http://localhost:8080/
15 changes: 15 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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
37 changes: 21 additions & 16 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,24 @@
<packaging>war</packaging>
<name>Struts Apps - Cookbook</name>
<version>1.0.0</version>

<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
</properties>
<repositories>
<repository>
<id>local-repo</id>
<url>file:../mvn-repo</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts-taglib</artifactId>
<version>1.3.10</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.3</version>
<scope>provided</scope>
<groupId>io.github.iwauo.springing-struts</groupId>
<artifactId>struts1-core</artifactId>
<version>0.0.5</version>
</dependency>
</dependencies>

<build>
<finalName>${project.artifactId}</finalName>
<resources>
<resource>
<directory>src/main/java</directory>
Expand All @@ -52,10 +53,14 @@
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.4.0</version>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>springing.struts1.entrypoint.Main</mainClass>
<layout>WAR</layout>
<version>3.2.5</version>
</configuration>
</plugin>
</plugins>
</plugins>
</build>
</project>
20 changes: 16 additions & 4 deletions scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,33 @@ 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() {
build && start
}

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 \
Expand Down