Skip to content

Commit f96f204

Browse files
authored
docker-compose-update
1 parent 004fbac commit f96f204

File tree

3 files changed

+42
-14
lines changed

3 files changed

+42
-14
lines changed

Dockerfile

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,24 @@
1-
FROM tomcat
1+
# Stage 1: Build Stage
2+
FROM openjdk:8 as build
23

4+
WORKDIR /app
5+
6+
# Copy the source code into the Docker image
37
COPY . .
48

5-
RUN apt-get update ; apt-get install maven default-jdk -y ; update-alternatives --config javac
9+
# Install Maven and JDK, then build the project
10+
RUN apt-get update && \
11+
apt-get install -y maven && \
12+
mvn clean package
13+
14+
# Stage 2: Runtime Stage
15+
FROM tomcat:7.0.82
16+
17+
# Copy the WAR file built in the previous stage
18+
COPY --from=build /app/target/*.war /usr/local/tomcat/webapps/
619

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

9-
CMD ["catalina.sh","run"]
23+
# CMD to start Tomcat
24+
CMD ["catalina.sh", "run"]

docker-compose.yml

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
1-
javavulnlab:
2-
build: .
3-
ports:
4-
- 8080:8080
5-
links:
6-
- mysql
71

8-
mysql:
9-
image: mysql
10-
environment:
11-
- MYSQL_ROOT_PASSWORD=root
2+
services:
3+
jvl:
4+
image: cspf/jvl
5+
build:
6+
dockerfile: ./Dockerfile
7+
context: ./
8+
ports:
9+
- 8080:8080
10+
links:
11+
- mysql
12+
13+
mysql:
14+
image: mysql:5.7
15+
environment:
16+
MYSQL_ROOT_PASSWORD: root
17+
MYSQL_ROOT_HOST: "%"
18+
MYSQL_DATABASE: abc
19+
command:
20+
- "--default-authentication-plugin=mysql_native_password"

pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,8 @@
4444
<build>
4545
<finalName>JavaVulnerableLab</finalName>
4646
</build>
47+
<properties>
48+
<maven.compiler.source>1.7</maven.compiler.source>
49+
<maven.compiler.target>1.7</maven.compiler.target>
50+
</properties>
4751
</project>

0 commit comments

Comments
 (0)