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
This commit is contained in:
Kristoffer Schneider 2017-03-02 21:31:40 +01:00 committed by Nanne Baars
parent 2b9185d85f
commit 26ab0dc712
3 changed files with 99 additions and 17 deletions

View File

@ -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

View File

@ -17,22 +17,43 @@
<start-class>org.owasp.webgoat.WebGoat</start-class>
</properties>
<profiles>
<profile>
<id>raspberry-pi-3</id>
<activation>
<property>
<name>rpi</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.4.10</version>
<configuration>
<imageName>webgoat/webgoat-8.0</imageName>
<dockerDirectory>src/main/docker_rpi3</dockerDirectory>
<resources>
<resource>
<directory>src/main/java</directory>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/application.properties</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.war</include>
</resource>
</resources>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>default</id>
<activation>
<property>
<name>!rpi</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>com.spotify</groupId>
@ -50,6 +71,28 @@
</resources>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<build>
<resources>
<resource>
<directory>src/main/java</directory>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/application.properties</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>

View File

@ -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"]