From 98edfafea5ae46aa4a97a5d17c25674c2bfaa595 Mon Sep 17 00:00:00 2001
From: Sonia Zorba <sonia.zorba@inaf.it>
Date: Tue, 20 Aug 2019 16:17:13 +0200
Subject: [PATCH] Started Dockerization

---
 .gitignore     |  1 +
 README.md      | 10 ++++++++++
 docker-env     |  7 +++++++
 gms/Dockerfile |  5 +++++
 gms/pom.xml    | 35 +++++++++++++++++++++++++++++++++++
 5 files changed, 58 insertions(+)
 create mode 100644 docker-env
 create mode 100644 gms/Dockerfile

diff --git a/.gitignore b/.gitignore
index 847b248..bbcf791 100644
--- a/.gitignore
+++ b/.gitignore
@@ -59,3 +59,4 @@ nbactions.xml
 
 /gms-client/gms-client-lib/target/
 /gms-client/gms-cli/target/
+/gms/node/
diff --git a/README.md b/README.md
index 4d923ce..7b8b824 100644
--- a/README.md
+++ b/README.md
@@ -9,3 +9,13 @@ To build the image run **from current directory**:
 To start the image and use the database:
 
     docker run -d -p 5432:5432 -i -t gms-db:latest
+
+## GMS Docker image
+
+To build the image:
+
+    mvn clean package dockerfile:build -DskipTests
+
+To run:
+
+    docker run --env-file docker-env -d -p 8081:8081 -i -t gms:latest
diff --git a/docker-env b/docker-env
new file mode 100644
index 0000000..0ad3091
--- /dev/null
+++ b/docker-env
@@ -0,0 +1,7 @@
+SPRING_DATASOURCE_URL=jdbc:postgresql://140.105.79.115:5432/postgres
+SECURITY_OAUTH2_CLIENT_ACCESS-TOKEN-URI=http://140.105.79.115/rap-ia2/auth/oauth2/token
+SECURITY_OAUTH2_CLIENT_USER-AUTHORIZATION-URI=http://localhost/rap-ia2/auth/oauth2/authorize
+SECURITY_OAUTH2_RESOURCE_TOKEN-INFO-URI=http://140.105.79.115/rap-ia2/auth/oauth2/check_token
+SECURITY_OAUTH2_RESOURCE_JWK_KEY-SET-URI=http://140.105.79.115/rap-ia2/auth/oidc/jwks
+RAP_WS-URL=http://140.105.79.115/rap-ia2/ws
+SPRING_PROFILES_ACTIVE=prod
diff --git a/gms/Dockerfile b/gms/Dockerfile
new file mode 100644
index 0000000..feded24
--- /dev/null
+++ b/gms/Dockerfile
@@ -0,0 +1,5 @@
+FROM openjdk:8-jdk-alpine
+VOLUME /tmp
+ARG JAR_FILE
+COPY target/${JAR_FILE} app.jar
+ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
diff --git a/gms/pom.xml b/gms/pom.xml
index 184d64b..71f2aa1 100644
--- a/gms/pom.xml
+++ b/gms/pom.xml
@@ -68,6 +68,30 @@
 
     <build>
         <plugins>
+            <plugin>
+                <groupId>com.github.eirslett</groupId>
+                <artifactId>frontend-maven-plugin</artifactId>
+                <version>1.7.6</version>
+                <configuration>
+                    <nodeVersion>v12.6.0</nodeVersion>
+                </configuration>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>install-node-and-npm</goal>
+                        </goals>
+                    </execution>
+                    <execution>
+                        <id>npm install</id>
+                        <goals>
+                            <goal>npm</goal>
+                        </goals>
+                        <configuration>
+                            <arguments>run build --prefix ../gms-ui</arguments>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
             <plugin>
                 <artifactId>maven-resources-plugin</artifactId>
                 <version>3.1.0</version>
@@ -89,6 +113,17 @@
                     </execution>
                 </executions>
             </plugin>
+            <plugin>
+                <groupId>com.spotify</groupId>
+                <artifactId>dockerfile-maven-plugin</artifactId>
+                <version>1.4.10</version>
+                <configuration>
+                    <repository>${project.artifactId}</repository>
+                    <buildArgs>
+                        <JAR_FILE>${project.build.finalName}.jar</JAR_FILE>
+                    </buildArgs>
+                </configuration>
+            </plugin>
             <plugin>
                 <groupId>org.springframework.boot</groupId>
                 <artifactId>spring-boot-maven-plugin</artifactId>
-- 
GitLab