diff --git a/Dockerfile b/Dockerfile index cb80dcf7..6597db0a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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"] diff --git a/default-tomcat.xml b/default-tomcat.xml new file mode 100644 index 00000000..a225d5e4 --- /dev/null +++ b/default-tomcat.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/docker-compose.yml b/docker-compose.yml index 672bcaca..23d7f3a3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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" diff --git a/pom.xml b/pom.xml index e90d5213..83e8cb7c 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ org.json json - 20090211 + 20231013 javax.servlet @@ -44,4 +44,8 @@ JavaVulnerableLab + + 1.7 + 1.7 +