FROM lscr.io/linuxserver/webtop:ubuntu-xfce
LABEL name="WebGoat: A deliberately insecure Web Application"
LABEL maintainer="WebGoat team"

WORKDIR /config

COPY target/webgoat-*.jar /config/webgoat.jar
COPY config/desktop/start_webgoat.sh /config/start_webgoat.sh
COPY config/desktop/start_zap.sh /config/start_zap.sh
COPY config/desktop/WebGoat.txt /config/Desktop/

RUN \
 apt-get update &&  \
 apt-get --yes install vim nano gzip

RUN \
 case $(uname -m) in \
  x86_64) ARCH=x64;; \
  aarch64) ARCH=aarch64;; \
  *) ARCH=unknown;; \
 esac && \
 echo ${ARCH}

RUN \
 curl -LO https://github.com/zaproxy/zaproxy/releases/download/v2.15.0/ZAP_2.15.0_Linux.tar.gz && \
 tar zfxv ZAP_2.15.0_Linux.tar.gz && \
 rm -rf ZAP_2.15.0_Linux.tar.gz

RUN \
 case $(uname -m) in \
  x86_64) ARCH=x64;; \
  aarch64) ARCH=aarch64;; \
  *) ARCH=unknown;; \
 esac && \
 echo "oeps == ${ARCH}==" && \
 curl -L https://github.com/adoptium/temurin23-binaries/releases/download/jdk-23.0.1%2B11/OpenJDK23U-jre_"${ARCH}"_linux_hotspot_23.0.1_11.tar.gz -o java.tar.gz && \
 tar zfxv java.tar.gz && \
 rm -rf java.tar.gz && \
 chmod +x /config/start_webgoat.sh && \
 chmod +x /config/start_zap.sh && \
 mv /config/jdk-23.0.1+11-jre /config/java-jdk && \
 echo "JAVA_HOME=/config/java-jdk/" >> .bash_aliases && \
 echo "PATH=$PATH:$JAVA_HOME/bin" >> .bash_aliases

ENV JAVA_HOME=/config/java-jdk

WORKDIR /config/Desktop
