summaryrefslogtreecommitdiffstats
path: root/dozentenmodulserver
diff options
context:
space:
mode:
authorManuel Bentele2021-03-09 10:47:55 +0100
committerManuel Bentele2021-03-11 07:46:19 +0100
commit208a9dd34b6bd4436599f857159e4c2b7290ea07 (patch)
treea2baf8bcd483c5cf19a5ceba774b73ff14516a81 /dozentenmodulserver
parent[client,server] Remove unused/empty unit tests (diff)
downloadtutor-module-208a9dd34b6bd4436599f857159e4c2b7290ea07.tar.gz
tutor-module-208a9dd34b6bd4436599f857159e4c2b7290ea07.tar.xz
tutor-module-208a9dd34b6bd4436599f857159e4c2b7290ea07.zip
[server] Build and run dozmod-server as Docker container
Diffstat (limited to 'dozentenmodulserver')
-rw-r--r--dozentenmodulserver/README.md28
-rw-r--r--dozentenmodulserver/docker-compose.yml53
-rw-r--r--dozentenmodulserver/pkg/docker/dozmod-server_dockerfile43
-rw-r--r--dozentenmodulserver/pom.xml69
-rw-r--r--dozentenmodulserver/setup/sat-01-testdata.sql2
5 files changed, 191 insertions, 4 deletions
diff --git a/dozentenmodulserver/README.md b/dozentenmodulserver/README.md
new file mode 100644
index 00000000..d5a48233
--- /dev/null
+++ b/dozentenmodulserver/README.md
@@ -0,0 +1,28 @@
+# dozmod-server - Server to manage virtual machine images
+
+## Build
+
+### Java package
+The dozmod-server can be built as a Java archive (.jar) using the following command line call:
+
+```shell
+mvn package
+```
+
+The built package can be found at `target/dozmod-server-*-jar-with-dependencies.jar`.
+
+
+### Docker container
+A docker image of the dozmod-server and its required infrastructure can be built and started with the following command line call:
+
+```shell
+mvn -P dozmod-server:start
+```
+
+Note that a complete Docker infrastructure (images, containers, networks and volumes) is created and started after this call. To stop the dozmod-server container and its entire infrastructure, use the following command line call:
+
+The running containers can be stopped with the following command line call:
+
+```shell
+mvn -P dozmod-server:stop
+```
diff --git a/dozentenmodulserver/docker-compose.yml b/dozentenmodulserver/docker-compose.yml
new file mode 100644
index 00000000..d19c06ba
--- /dev/null
+++ b/dozentenmodulserver/docker-compose.yml
@@ -0,0 +1,53 @@
+version: "3"
+services:
+ dozmod-server:
+ container_name: dozmod-server
+ image: dozmod-server:latest
+ hostname: dozmod-server
+ build:
+ context: .
+ dockerfile: pkg/docker/dozmod-server_dockerfile
+ args:
+ DOZMOD_MASTER_SERVER: bwlp-masterserver.ruf.uni-freiburg.de
+ DOZMOD_SERVER_FILE: target/dozmod-server-1.0-SNAPSHOT-jar-with-dependencies.jar
+ DOZMOD_CONFIG_FILE: setup/config.properties
+ DOZMOD_DATABASE_NAME: sat
+ DOZMOD_DATABASE_HOST: 192.168.200.20
+ DOZMOD_DATABASE_USER: root
+ DOZMOD_DATABASE_PASSWORD: dozmod
+ depends_on:
+ - dozmod-database
+ networks:
+ dozmod:
+ ipv4_address: 192.168.200.10
+ ipv6_address: fd03:4b1d:5707:c8::a
+ dozmod-database:
+ container_name: dozmod-database
+ image: mariadb:latest
+ restart: always
+ hostname: dozmod-database
+ environment:
+ MYSQL_DATABASE: sat
+ MYSQL_ROOT_PASSWORD: dozmod
+ volumes:
+ - dozmod-database:/var/lib/mysql
+ - ./setup:/docker-entrypoint-initdb.d
+ networks:
+ dozmod:
+ ipv4_address: 192.168.200.20
+ ipv6_address: fd03:4b1d:5707:c8::14
+volumes:
+ dozmod-database:
+ name: dozmod-database
+networks:
+ dozmod:
+ name: dozmod
+ driver: bridge
+ enable_ipv6: true
+ ipam:
+ driver: default
+ config:
+ - subnet: 192.168.200.0/24
+ gateway: 192.168.200.1
+ - subnet: fd03:4b1d:5707:c8::/64
+ gateway: fd03:4b1d:5707:c8::1
diff --git a/dozentenmodulserver/pkg/docker/dozmod-server_dockerfile b/dozentenmodulserver/pkg/docker/dozmod-server_dockerfile
new file mode 100644
index 00000000..cb372793
--- /dev/null
+++ b/dozentenmodulserver/pkg/docker/dozmod-server_dockerfile
@@ -0,0 +1,43 @@
+FROM ubuntu:focal
+
+ARG DOZMOD_SERVER_FILE
+ARG DOZMOD_CONFIG_FILE
+ARG DOZMOD_MASTER_SERVER=localhost
+ARG DOZMOD_SERVER_PATH=/opt/bwLehrpool
+ARG DOZMOD_VSTORE_PATH=/mnt/bwLehrpool
+ARG DOZMOD_DATABASE_NAME=dozmod
+ARG DOZMOD_DATABASE_HOST=localhost
+ARG DOZMOD_DATABASE_USER=dozmod
+ARG DOZMOD_DATABASE_PASSWORD=dozmod
+
+# install required packages
+RUN apt-get update -y && \
+ apt-get install -y openjdk-8-jre-headless
+
+# make folder for dozmod Java server application and VMs
+RUN mkdir -p ${DOZMOD_SERVER_PATH}
+RUN mkdir -p ${DOZMOD_VSTORE_PATH}
+
+# change working directory
+WORKDIR ${DOZMOD_SERVER_PATH}
+
+# copy application and configuration file
+COPY ${DOZMOD_SERVER_FILE} dozmod-server.jar
+
+# customize configuration
+RUN echo "#" \
+ "\n""# Autogenerated configuration. Do not edit!" \
+ "\n""#" \
+ "\n""vmstore.path = ${DOZMOD_VSTORE_PATH}" \
+ "\n""db.uri = jdbc:mysql://${DOZMOD_DATABASE_HOST}/${DOZMOD_DATABASE_NAME}?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&characterSetResults=utf8&connectionCollation=utf8mb4_unicode_ci" \
+ "\n""db.username = ${DOZMOD_DATABASE_USER}" \
+ "\n""db.password = ${DOZMOD_DATABASE_PASSWORD}" \
+ "\n""db.location-table = " \
+ "\n""master.address = ${DOZMOD_MASTER_SERVER}" > config.properties && \
+ sed -i 's/[[:space:]]\+$//' config.properties
+
+# expose network ports
+EXPOSE 9080 9090 9091
+
+# run the dozmod-server
+CMD [ "java", "-jar", "dozmod-server.jar" ]
diff --git a/dozentenmodulserver/pom.xml b/dozentenmodulserver/pom.xml
index 2c8abb4e..43339e0d 100644
--- a/dozentenmodulserver/pom.xml
+++ b/dozentenmodulserver/pom.xml
@@ -1,4 +1,5 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -31,6 +32,68 @@
</repository>
</repositories>
+ <profiles>
+ <profile>
+ <id>dozmod-server:start</id>
+ <build>
+ <defaultGoal>pre-integration-test</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>3.0.0</version>
+ <executions>
+ <execution>
+ <id>docker-compose:up</id>
+ <phase>pre-integration-test</phase>
+ <goals>
+ <goal>exec</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <executable>docker-compose</executable>
+ <arguments>
+ <argument>up</argument>
+ <argument>--build</argument>
+ <argument>--force-recreate</argument>
+ <argument>--detach</argument>
+ </arguments>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>dozmod-server:stop</id>
+ <build>
+ <defaultGoal>validate</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>3.0.0</version>
+ <executions>
+ <execution>
+ <id>docker-compose:down</id>
+ <phase>validate</phase>
+ <goals>
+ <goal>exec</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <executable>docker-compose</executable>
+ <arguments>
+ <argument>down</argument>
+ </arguments>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
<build>
<plugins>
<plugin>
@@ -82,8 +145,8 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
- <useSystemClassLoader>false</useSystemClassLoader>
- </configuration>
+ <useSystemClassLoader>false</useSystemClassLoader>
+ </configuration>
</plugin>
</plugins>
</build>
diff --git a/dozentenmodulserver/setup/sat-01-testdata.sql b/dozentenmodulserver/setup/sat-01-testdata.sql
index f01c7024..95378468 100644
--- a/dozentenmodulserver/setup/sat-01-testdata.sql
+++ b/dozentenmodulserver/setup/sat-01-testdata.sql
@@ -22,7 +22,7 @@ INSERT INTO `operatingsystem` (`osid`, `displayname`, `architecture`, `maxmem`,
(11, 'Windows 2000 Professional', 'x86', 4096, 4);
INSERT INTO `virtualizer` (`virtid`, `virtname`) VALUES
-('vmware', 'VMware');
+('vmware', 'VMware'),('virtualbox', 'VirtualBox'),('qemukvm', 'QEMU'),('docker', 'Docker');
INSERT INTO `os_x_virt` VALUES
(6,'vmware','opensuse'),(7,'vmware','opensuse-64'),(8,'vmware','other3xlinux'),(9,'vmware','other3xlinux-64'),(4,'vmware','ubuntu'),(5,'vmware','ubuntu-64'),(10,'vmware','windows7'),(1,'vmware','windows7-64'),(2,'vmware','windows8'),(3,'vmware','windows8-64');