Skip to content

Commit

Permalink
Ensure that insecure-bank can be deployed as a war
Browse files Browse the repository at this point in the history
  • Loading branch information
manuel-alvarez-alvarez committed Apr 23, 2024
1 parent d573903 commit 09fe0a0
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
30 changes: 14 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,27 @@ COPY --chown=gradle:gradle . /home/gradle/src
WORKDIR /home/gradle/src
RUN gradle :bootWar --no-daemon

FROM openjdk:8u342-jre-slim

WORKDIR /app
FROM tomcat:8.5.100-jre8

RUN mkdir /app
COPY --from=log4j /home/gradle/src/malicious-server/build/libs/*.jar /app/malicious-server.jar
COPY --from=app /home/gradle/src/build/libs/*.war /app/insecure-bank.war

ADD start.sh /app/start.sh
WORKDIR /usr/local/tomcat
ADD start.sh /usr/local/tomcat/

RUN chmod +x /app/start.sh
# Copy the application to tomcat
COPY --from=app /home/gradle/src/build/libs/*.war /usr/local/tomcat/webapps/insecure-bank.war

# Copy the license file
ADD license.hdiv /app/hdiv/
ADD license.hdiv /usr/local/tomcat/hdiv/

# Copy the agent jar
ADD hdiv-ee-agent.jar /app/hdiv/

ENV JAVA_OPTS="-javaagent:/app/hdiv/hdiv-ee-agent.jar \
-Dhdiv.config.dir=/app/hdiv/ \
-Dhdiv.console.url=http://console:8080/hdiv-console-services \
-Dhdiv.console.token=04db250da579302ca273a958 \
-Dhdiv.server.name=Testing-Docker \
-Dhdiv.toolbar.enabled=true"
ADD hdiv-ee-agent.jar /usr/local/tomcat/hdiv/

# Run Tomcat and enjoy!
CMD /app/start.sh
CMD export JAVA_OPTS="-javaagent:hdiv/hdiv-ee-agent.jar \
-Dhdiv.config.dir=hdiv/ \
-Dhdiv.console.url=http://console:8080/hdiv-console-services \
-Dhdiv.console.token=04db250da579302ca273a958 \
-Dhdiv.server.name=Testing-Docker \
-Dhdiv.toolbar.enabled=true" && ./start.sh
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

$ git clone https://github.com/hdiv/insecure-bank.git
2. Run the application:
2. Run the application locally:

$ ./gradlew bootRun

Expand All @@ -22,7 +22,7 @@ Place Hdiv agent and license in the application root folder.
$ docker run -p 8080:8080 -d --name insecure-bank-app insecure-bank
$ docker logs insecure-bank-app

Open the application in > http://localhost:8080/
Open the application in > http://localhost:8080/insecure-bank

## Login credentials
- Username: john
Expand Down
2 changes: 2 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ dependencies {
runtimeOnly("javax.servlet:jstl")
runtimeOnly("org.apache.tomcat.embed:tomcat-embed-jasper")
runtimeOnly("org.hsqldb:hsqldb")

providedRuntime("org.springframework.boot:spring-boot-starter-tomcat")
}

tasks.withType<Test> {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/hdivsamples/InsecureBankApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;

@SpringBootApplication
public class InsecureBankApplication {
public class InsecureBankApplication extends SpringBootServletInitializer {

public static void main(String[] args) {
SpringApplication.run(InsecureBankApplication.class, args);
Expand Down
2 changes: 1 addition & 1 deletion start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

java -jar /app/malicious-server.jar &

java ${JAVA_OPTS} -jar /app/insecure-bank.war
./bin/catalina.sh run

0 comments on commit 09fe0a0

Please sign in to comment.