Move to different base image for Java

This way we can also support arm/v7
This commit is contained in:
Nanne Baars 2021-10-23 20:57:16 +02:00 committed by Nanne Baars
parent cc0d0fa2a6
commit 981fcb3ebc
5 changed files with 35 additions and 37 deletions

View File

@ -94,7 +94,7 @@ jobs:
context: ./docker
file: docker/Dockerfile
push: true
platforms: linux/amd64, linux/arm64
platforms: linux/amd64, linux/arm64, linux/arm/v7
tags: |
webgoat/goatandwolf:${{ env.WEBGOAT_TAG_VERSION }}
webgoat/goatandwolf:latest

View File

@ -1,7 +1,4 @@
FROM openjdk:16-slim
ARG webgoat_version=8.2.1-SNAPSHOT
ENV webgoat_version_env=${webgoat_version}
FROM eclipse-temurin:16.0.2_7-jdk-focal
RUN apt-get update
RUN useradd -ms /bin/bash webgoat
@ -11,12 +8,12 @@ USER webgoat
COPY --chown=webgoat nginx.conf /etc/nginx/nginx.conf
COPY --chown=webgoat index.html /usr/share/nginx/html/
COPY --chown=webgoat target/webgoat-server-${webgoat_version}.jar /home/webgoat/webgoat.jar
COPY --chown=webgoat target/webwolf-${webgoat_version}.jar /home/webgoat/webwolf.jar
COPY --chown=webgoat target/webgoat-server-*.jar /home/webgoat/webgoat.jar
COPY --chown=webgoat target/webwolf-*.jar /home/webgoat/webwolf.jar
COPY --chown=webgoat start.sh /home/webgoat
EXPOSE 8080
EXPOSE 9090
WORKDIR /home/webgoat
ENTRYPOINT /bin/bash /home/webgoat/start.sh $webgoat_version_env
ENTRYPOINT /bin/bash start.sh

6
docker/start.sh Normal file → Executable file
View File

@ -16,11 +16,11 @@ java \
--add-opens java.desktop/java.awt.font=ALL-UNNAMED \
--add-opens java.base/sun.nio.ch=ALL-UNNAMED \
--add-opens java.base/java.io=ALL-UNNAMED \
-jar webgoat.jar --webgoat.build.version="$1" --server.address=0.0.0.0 > webgoat.log &
-jar webgoat.jar --server.address=0.0.0.0 > webgoat.log &
echo "Starting WebWolf..."
java -Duser.home=/home/webgoat -Dfile.encoding=UTF-8 -jar webwolf.jar --webgoat.build.version=$1 --server.address=0.0.0.0 > webwolf.log &
java -Duser.home=/home/webgoat -Dfile.encoding=UTF-8 -jar webwolf.jar --server.address=0.0.0.0 > webwolf.log &
echo "Browse to http://localhost to get started" >> webgoat.log
tail -300f webgoat.log
exec tail -300f webgoat.log

View File

@ -26,10 +26,12 @@ import java.io.IOException;
import java.net.Socket;
import org.owasp.webwolf.requests.WebWolfTraceRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.actuate.trace.http.HttpTraceRepository;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Profile;
@SpringBootApplication
public class WebWolf {
@ -43,19 +45,18 @@ public class WebWolf {
System.setProperty("spring.config.name", "application-webwolf");
String webwolfPort = System.getenv("WEBWOLF_PORT");
String webGoatHost = null==System.getenv("WEBGOAT_HOST")?"127.0.0.1":System.getenv("WEBGOAT_HOST");
String webWolfHost = null == System.getenv("WEBWOLF_HOST") ? "127.0.0.1" : System.getenv("WEBWOLF_HOST");
String fileEncoding = System.getProperty("file.encoding");
int wolfPort = webwolfPort == null ? 9090 : Integer.parseInt(webwolfPort);
if (null == fileEncoding || !fileEncoding.equals("UTF-8")) {
System.out.println("It seems the application is startd on a OS with non default UTF-8 encoding:"+fileEncoding);
System.out.println("It seems the application is started on a OS with non default UTF-8 encoding:" + fileEncoding);
System.out.println("Please add: -Dfile.encoding=UTF-8");
System.exit(-1);
}
if (isAlreadyRunning(webGoatHost, wolfPort)) {
if (isAlreadyRunning(webWolfHost, wolfPort)) {
System.out.println("Port " + webWolfHost + ":" + wolfPort + " is in use. Use environment value WEBWOLF_PORT to set a different value.");
System.exit(-1);
}