Skip to content
Open

asd #45

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
23 changes: 19 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
FROM tomcat
# Stage 1: Build Stage
FROM openjdk:8 as build

WORKDIR /app

# Copy the source code into the Docker image
COPY . .

RUN apt-get update ; apt-get install maven default-jdk -y ; update-alternatives --config javac
# Install Maven and JDK, then build the project
RUN apt-get update && \
apt-get install -y maven && \
mvn clean package

# Stage 2: Runtime Stage
FROM tomcat:7.0.82

# Copy the WAR file built in the previous stage
COPY --from=build /app/target/*.war /usr/local/tomcat/webapps/

RUN mvn clean package ; cp target/*.war /usr/local/tomcat/webapps/
# Copy the pre-prepared tomcat-users.xml to set up user roles
COPY default-tomcat.xml /usr/local/tomcat/conf/tomcat-users.xml

CMD ["catalina.sh","run"]
# CMD to start Tomcat
CMD ["catalina.sh", "run"]
6 changes: 6 additions & 0 deletions default-tomcat.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<tomcat-users>
<!-- Define a user with manager-gui role -->
<role rolename="manager-gui"/>
<user username="tomcat" password="s3cret" roles="manager-gui"/>
</tomcat-users>

29 changes: 19 additions & 10 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
javavulnlab:
build: .
ports:
- 8080:8080
links:
- mysql

mysql:
image: mysql
environment:
- MYSQL_ROOT_PASSWORD=root
services:
jvl:
image: cspf/jvl
build:
dockerfile: ./Dockerfile
context: ./
ports:
- 8080:8080
links:
- mysql

mysql:
image: mysql:5.7
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_ROOT_HOST: "%"
MYSQL_DATABASE: abc
command:
- "--default-authentication-plugin=mysql_native_password"
6 changes: 5 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20090211</version>
<version>20231013</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
Expand All @@ -44,4 +44,8 @@
<build>
<finalName>JavaVulnerableLab</finalName>
</build>
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
</project>