From 26ab0dc71281e0c879b85ea3ea52d5d541b94eeb Mon Sep 17 00:00:00 2001 From: Kristoffer Schneider Date: Thu, 2 Mar 2017 21:31:40 +0100 Subject: [PATCH] Added support to build an Docker container to run it on Raspberry Pi (#329) Added support to build an Docker container to run it on Raspberry Pi #329 --- README.MD | 31 +++++++- webgoat-container/pom.xml | 75 +++++++++++++++---- .../src/main/docker_rpi3/Dockerfile | 10 +++ 3 files changed, 99 insertions(+), 17 deletions(-) create mode 100644 webgoat-container/src/main/docker_rpi3/Dockerfile diff --git a/README.MD b/README.MD index b837af712..df4c291d1 100644 --- a/README.MD +++ b/README.MD @@ -93,18 +93,47 @@ The source code will be available in the home directory. # Building a new Docker image -WebGoat now has Docker support you can build a container with the following commands: +WebGoat now has Docker support for x86 and ARM (raspberry pi). +### Docker on x86 +On x86 you can build a container with the following commands: ```Shell cd WebGoat/ mvn package cd webgoat-container +mvn package mvn docker:build docker tag webgoat/webgoat-8.0 webgoat/webgoat-8.0:8.0 docker login docker push webgoat/webgoat-container ``` +### Docker on ARM (Raspberry Pi) +On a Raspberry Pi (it has yet been tested with a Raspberry Pi 3 and the hypriot Docker image) you need to build JFFI for +ARM first. This is needed by the docker-maven-plugin ([see here](https://github.com/spotify/docker-maven-plugin/issues/233)): + +```Shell +sudo apt-get install build-essential +git clone https://github.com/jnr/jffi.git +cd jffi +ant jar +cd build/jni +sudo cp libjffi-1.2.so /usr/lib +``` + +When you have done this you can build the Docker container using the following commands: + +```Shell +cd WebGoat/ +mvn package +cd webgoat-container +mvn package +mvn docker:build -Drpi=true +docker tag webgoat/webgoat-8.0 webgoat/webgoat-8.0:8.0 +docker login +docker push webgoat/webgoat-container +``` + With the following command you are able to run the Docker container on your local machine: ```Shell diff --git a/webgoat-container/pom.xml b/webgoat-container/pom.xml index 5a1493b62..3fed15cd1 100644 --- a/webgoat-container/pom.xml +++ b/webgoat-container/pom.xml @@ -17,6 +17,65 @@ org.owasp.webgoat.WebGoat + + + raspberry-pi-3 + + + rpi + + + + + + com.spotify + docker-maven-plugin + 0.4.10 + + webgoat/webgoat-8.0 + src/main/docker_rpi3 + + + / + ${project.build.directory} + ${project.build.finalName}.war + + + + + + + + + default + + + !rpi + + + + + + com.spotify + docker-maven-plugin + 0.4.10 + + webgoat/webgoat-8.0 + src/main/docker + + + / + ${project.build.directory} + ${project.build.finalName}.war + + + + + + + + + @@ -34,22 +93,6 @@ - - com.spotify - docker-maven-plugin - 0.4.10 - - webgoat/webgoat-8.0 - src/main/docker - - - / - ${project.build.directory} - ${project.build.finalName}.war - - - - org.apache.maven.plugins maven-jar-plugin diff --git a/webgoat-container/src/main/docker_rpi3/Dockerfile b/webgoat-container/src/main/docker_rpi3/Dockerfile new file mode 100644 index 000000000..140a745ad --- /dev/null +++ b/webgoat-container/src/main/docker_rpi3/Dockerfile @@ -0,0 +1,10 @@ +# Baseimage specially for raspberry pi usage +FROM resin/rpi-raspbian:jessie +VOLUME /tmp +# Installing openjdk-8-headless like in the standard Webgoat Docker container +RUN apt-get update && apt-get install -y \ + openjdk-8-jre-headless +RUN cd /root; mkdir -p .webgoat +ADD webgoat-container-8.0-SNAPSHOT.war webgoat.jar +RUN sh -c 'touch /webgoat.jar' +ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/webgoat.jar"] \ No newline at end of file