All in one docker (#749)
* all-in-one Dockerfile preparations * some cleanup * add to main pom and add links in index.html * updated deploy script from build pipeline * additional line feed just in case
This commit is contained in:
parent
4e371b63d0
commit
9eee726eb5
1
docker/.gitignore
vendored
Normal file
1
docker/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
*.jar
|
30
docker/Dockerfile
Normal file
30
docker/Dockerfile
Normal file
@ -0,0 +1,30 @@
|
||||
FROM openjdk:11.0.1-jre-slim-stretch
|
||||
|
||||
ARG webgoat_version=v8.0.0-SNAPSHOT
|
||||
ENV webgoat_version_env=${webgoat_version}
|
||||
|
||||
RUN apt-get update && apt-get install
|
||||
RUN useradd --home-dir /home/webgoat --create-home -U webgoat
|
||||
RUN apt-get -y install apt-utils nginx
|
||||
|
||||
USER webgoat
|
||||
RUN cd /home/webgoat/; mkdir -p .webgoat-${webgoat_version}
|
||||
|
||||
COPY nginx.conf /etc/nginx/nginx.conf
|
||||
COPY index.html /usr/share/nginx/html/
|
||||
COPY webgoat-server-${webgoat_version}.jar /home/webgoat/webgoat.jar
|
||||
COPY webwolf-${webgoat_version}.jar /home/webgoat/webwolf.jar
|
||||
COPY start.sh /home/webgoat
|
||||
|
||||
EXPOSE 8080
|
||||
EXPOSE 9090
|
||||
|
||||
ENV WEBGOAT_PORT 8080
|
||||
ENV WEBGOAT_SSLENABLED false
|
||||
|
||||
ENV GOATURL https://127.0.0.1:$WEBGOAT_PORT
|
||||
ENV WOLFURL http://127.0.0.1:9090
|
||||
|
||||
|
||||
WORKDIR /home/webgoat
|
||||
ENTRYPOINT /bin/bash /home/webgoat/start.sh $webgoat_version_env
|
9
docker/Readme.md
Normal file
9
docker/Readme.md
Normal file
@ -0,0 +1,9 @@
|
||||
# Docker all-in-one image
|
||||
|
||||
## Docker build
|
||||
|
||||
docker build --no-cache --build-arg webgoat_version=v8.0.0-SNAPSHOT -t webgoat/goatandwolf:latest .
|
||||
|
||||
## Docker run
|
||||
|
||||
docker run -d -p 80:8888 -p 8080:8080 -p 9090:9090 -e TZ=Europe/Amsterdam webgoat/goatandwolf:latest
|
43
docker/index.html
Normal file
43
docker/index.html
Normal file
@ -0,0 +1,43 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
<h1>OWASP WebGoat Training tools</h1>
|
||||
<p>
|
||||
Use the following links to access the WebGoat and WebWolf applications.
|
||||
Register a user using WebGoat. The same user can access WebWolf.
|
||||
</p>
|
||||
|
||||
<h2>Use without special host name entries</h2>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td>WebGoat URL</td>
|
||||
<td><a href="http://127.0.0.1:8080/WebGoat" target="_blank">http://127.0.0.1:8080/WebGoat</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>WebWolf URL</td>
|
||||
<td><a href="http://127.0.0.1:9090/WebWolf" target="_blank">http://127.0.0.1:9090/WebWolf</a></td>
|
||||
</tr>
|
||||
<table>
|
||||
|
||||
<h2>Use with www.webgoat.local and www.webwolf.local</h2>
|
||||
<p>
|
||||
Add the following entries to your local <b><i>hosts</i></b> file on Windows (c:\Windows\System32\drivers\etc\hosts) or Linux (/etc/hosts)
|
||||
|
||||
<pre>
|
||||
127.0.0.1 www.webgoat.local www.webwolf.local
|
||||
</pre>
|
||||
Then use the following URL's:
|
||||
</p>
|
||||
<table>
|
||||
<tr>
|
||||
<td>WebGoat URL</td>
|
||||
<td><a href="http://www.webgoat.local/WebGoat" target="_blank">http://www.webgoat.local/WebGoat</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>WebWolf URL</td>
|
||||
<td><a href="http://www.webwolf.local/WebWolf" target="_blank">http://www.webwolf.local/WebWolf</a></td>
|
||||
</tr>
|
||||
<table>
|
||||
</body>
|
||||
</html>
|
140
docker/nginx.conf
Normal file
140
docker/nginx.conf
Normal file
@ -0,0 +1,140 @@
|
||||
error_log /tmp/error.log;
|
||||
pid /tmp/nginx.pid;
|
||||
|
||||
worker_processes 1;
|
||||
|
||||
events { worker_connections 1024; }
|
||||
|
||||
http {
|
||||
|
||||
client_body_temp_path /tmp/client_body;
|
||||
fastcgi_temp_path /tmp/fastcgi_temp;
|
||||
proxy_temp_path /tmp/proxy_temp;
|
||||
scgi_temp_path /tmp/scgi_temp;
|
||||
uwsgi_temp_path /tmp/uwsgi_temp;
|
||||
|
||||
sendfile on;
|
||||
|
||||
upstream docker-webgoat {
|
||||
server 127.0.0.1:8080;
|
||||
}
|
||||
|
||||
upstream docker-webwolf {
|
||||
server 127.0.0.1:9090;
|
||||
}
|
||||
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Host $server_name;
|
||||
|
||||
server {
|
||||
listen 8888;
|
||||
server_name www.webgoat.local;
|
||||
|
||||
root /var/www;
|
||||
|
||||
access_log /tmp/goataccess.log;
|
||||
error_log /tmp/goaterror.log;
|
||||
|
||||
location ~* \.(png|jpg|jpeg|gif|ico|woff|otf|ttf|mvc|svg|txt|pdf|docx?|xlsx?)$ {
|
||||
access_log off;
|
||||
proxy_pass http://docker-webgoat;
|
||||
proxy_redirect off;
|
||||
}
|
||||
|
||||
location / {
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
add_header Cache-Control no-cache;
|
||||
expires 0;
|
||||
}
|
||||
|
||||
location /WebGoat {
|
||||
proxy_pass http://docker-webgoat;
|
||||
proxy_redirect off;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
server {
|
||||
listen 8888;
|
||||
server_name www.webwolf.local;
|
||||
|
||||
root /var/www;
|
||||
|
||||
access_log /tmp/wolfaccess.log;
|
||||
error_log /tmp/wolferror.log;
|
||||
|
||||
location /WebGoat/PasswordReset/ForgotPassword/create-password-reset-link {
|
||||
proxy_pass http://docker-webgoat;
|
||||
proxy_redirect off;
|
||||
}
|
||||
|
||||
location /PasswordReset/reset/reset-password {
|
||||
proxy_pass http://docker-webwolf;
|
||||
proxy_redirect off;
|
||||
}
|
||||
|
||||
location /files {
|
||||
proxy_pass http://docker-webwolf;
|
||||
proxy_redirect off;
|
||||
}
|
||||
|
||||
location /tmpdir {
|
||||
proxy_pass http://docker-webwolf;
|
||||
proxy_redirect off;
|
||||
}
|
||||
|
||||
location /webjars {
|
||||
proxy_pass http://docker-webwolf;
|
||||
proxy_redirect off;
|
||||
}
|
||||
|
||||
location /css {
|
||||
proxy_pass http://docker-webwolf;
|
||||
proxy_redirect off;
|
||||
}
|
||||
|
||||
location /login {
|
||||
proxy_pass http://docker-webwolf;
|
||||
proxy_redirect off;
|
||||
}
|
||||
|
||||
location /images {
|
||||
proxy_pass http://docker-webwolf;
|
||||
proxy_redirect off;
|
||||
}
|
||||
|
||||
location /mail {
|
||||
proxy_pass http://docker-webwolf;
|
||||
proxy_redirect off;
|
||||
}
|
||||
|
||||
location /upload {
|
||||
proxy_pass http://docker-webwolf;
|
||||
proxy_redirect off;
|
||||
}
|
||||
|
||||
location /js {
|
||||
proxy_pass http://docker-webwolf;
|
||||
proxy_redirect off;
|
||||
}
|
||||
|
||||
location /landing {
|
||||
proxy_pass http://docker-webwolf;
|
||||
proxy_redirect off;
|
||||
}
|
||||
|
||||
location /logout {
|
||||
proxy_pass http://docker-webwolf;
|
||||
proxy_redirect off;
|
||||
}
|
||||
|
||||
location /WebWolf {
|
||||
proxy_pass http://docker-webwolf;
|
||||
proxy_redirect off;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
40
docker/pom.xml
Normal file
40
docker/pom.xml
Normal file
@ -0,0 +1,40 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>webgoat-all-in-one-docker</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<parent>
|
||||
<groupId>org.owasp.webgoat</groupId>
|
||||
<artifactId>webgoat-parent</artifactId>
|
||||
<version>v8.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<version>1.8</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>install</phase>
|
||||
<configuration>
|
||||
<target>
|
||||
<copy file="../webgoat-server/target/webgoat-server-${project.version}.jar" tofile="webgoat-server-${project.version}.jar"/>
|
||||
<copy file="../webwolf/target/webwolf-${project.version}.jar" tofile="webwolf-${project.version}.jar"/>
|
||||
</target>
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
12
docker/start.sh
Normal file
12
docker/start.sh
Normal file
@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd /home/webgoat
|
||||
service nginx start
|
||||
sleep 1
|
||||
java -Dfile.encoding=UTF-8 -jar webgoat.jar --webgoat.build.version=$1 --server.address=0.0.0.0 > webgoat.log &
|
||||
|
||||
sleep 10
|
||||
|
||||
java -Dfile.encoding=UTF-8 -jar webwolf.jar --webgoat.build.version=$1 --server.address=0.0.0.0 > webwolf.log &
|
||||
|
||||
tail -300f webgoat.log
|
1
pom.xml
1
pom.xml
@ -144,6 +144,7 @@
|
||||
<module>webgoat-server</module>
|
||||
<module>webwolf</module>
|
||||
<module>webgoat-integration-tests</module>
|
||||
<module>docker</module><!-- copy required jars in preparation of docker all-in-one build -->
|
||||
</modules>
|
||||
|
||||
<dependencies>
|
||||
|
@ -33,4 +33,17 @@ if [ ! -z "${TRAVIS_TAG}" ]; then
|
||||
docker push $REPO
|
||||
else
|
||||
echo "Skipping releasing to DockerHub because it is a build of branch ${BRANCH}"
|
||||
fi
|
||||
fi
|
||||
|
||||
export REPO=webgoat/goatandwolf
|
||||
cd ..
|
||||
cd docker
|
||||
ls target/
|
||||
|
||||
if [ ! -z "${TRAVIS_TAG}" ]; then
|
||||
# If we push a tag to master this will update the LATEST Docker image and tag with the version number
|
||||
docker build --build-arg webgoat_version=${TRAVIS_TAG:1} -f Dockerfile -t $REPO:latest -t $REPO:${TRAVIS_TAG} .
|
||||
docker push $REPO
|
||||
else
|
||||
echo "Skipping releasing to DockerHub because it is a build of branch ${BRANCH}"
|
||||
fi
|
||||
|
Loading…
x
Reference in New Issue
Block a user