From 6b39a1326436ca0b7a612cea366f37e2a4ef9a72 Mon Sep 17 00:00:00 2001
From: Sonia Zorba <sonia.zorba@inaf.it>
Date: Fri, 14 May 2021 17:39:09 +0200
Subject: [PATCH] Dockerfile changes

---
 README.md      | 20 +++-----------------
 docker-env     |  7 -------
 gms/Dockerfile | 36 +++++++++++++++++++++++++++++++-----
 3 files changed, 34 insertions(+), 29 deletions(-)
 delete mode 100644 docker-env

diff --git a/README.md b/README.md
index 82983d7..7e3a426 100644
--- a/README.md
+++ b/README.md
@@ -1,24 +1,10 @@
 # IA2 GMS
 
-## Database Docker image
+## Docker images
 
-To build the image run **from current directory**:
+Docker images are available on [container registry page](https://www.ict.inaf.it/gitlab/ia2/ia2-gms/container_registry).
 
-    docker build -f database/Dockerfile --tag gms-db .
-
-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
+A working demo using Docker Compose is available on [RAP repository](https://www.ict.inaf.it/gitlab/ia2/rap-ia2).
 
 ## Create the first super-admin
 
diff --git a/docker-env b/docker-env
deleted file mode 100644
index 0ad3091..0000000
--- a/docker-env
+++ /dev/null
@@ -1,7 +0,0 @@
-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
index feded24..41e9b58 100644
--- a/gms/Dockerfile
+++ b/gms/Dockerfile
@@ -1,5 +1,31 @@
-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"]
+FROM node:15 
+
+ADD gms-ui/package*.json /gms-ui/
+
+WORKDIR /gms-ui
+
+RUN npx browserslist@latest --update-db
+RUN npm ci
+
+ADD gms-ui/src /gms-ui/src/
+ADD gms-ui/public /gms-ui/public/
+ADD gms-ui/*.js /gms-ui/
+ADD gms-ui/*.json /gms-ui/
+ADD gms-ui/.env.production /gms-ui/
+
+RUN npm run build
+
+FROM maven:3.6.3-openjdk-14
+
+COPY --from=0 /gms-ui/dist/. /gms-ui/dist/
+
+ADD gms/pom.xml /gms/pom.xml
+ADD gms/src /gms/src/
+
+WORKDIR /gms
+
+RUN mvn clean package -DskipTests
+
+FROM openjdk:14-jdk-alpine
+COPY --from=1 /gms/target/gms.jar /gms.jar
+ENTRYPOINT ["java","-jar","/gms.jar"]
-- 
GitLab