From 700d7972a37b450f0d938f76e5866d1238b0ee5b Mon Sep 17 00:00:00 2001
From: Alessandro Cerioni <acerioni@grandlyon.com>
Date: Wed, 4 Dec 2019 18:30:17 +0100
Subject: [PATCH] Base href updated to /admin

---
 Dockerfile          | 17 +++++++++++++++--
 angular.json        |  2 +-
 docker-compose.yml  |  8 ++++----
 nginx.conf.template | 14 ++++++++------
 4 files changed, 28 insertions(+), 13 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index e441522..4c01be6 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -7,7 +7,14 @@ WORKDIR /app
 # Install npm dependencies
 RUN npm install
 # Copy the project
-COPY . /app
+COPY tsconfig.json /app
+COPY angular.json /app
+COPY patch.js /app
+COPY config /app/config
+COPY src /app/src
+
+RUN ls /app
+
 
 # Launch postinstall script (to include crypto module)
 RUN npm run postinstall
@@ -20,7 +27,13 @@ RUN npm run build:${conf}
 # Stage 1, based on Nginx, to have only the compiled app
 FROM nginx
 
-COPY --from=builder /app/dist/admin-gui /usr/share/nginx/html
+## Install dependency to get lua module in .conf 
+RUN apt-get update 
+RUN apt-get --assume-yes install nginx-extras
+
+RUN rm /etc/nginx/conf.d/*
+
+COPY --from=builder /app/dist/admin-gui /usr/share/nginx/html/admin
 RUN ls -l /usr/share/nginx/html
 EXPOSE 80
 
diff --git a/angular.json b/angular.json
index 5aa6d59..df87937 100644
--- a/angular.json
+++ b/angular.json
@@ -145,4 +145,4 @@
       "prefix": "app"
     }
   }
-}
\ No newline at end of file
+}
diff --git a/docker-compose.yml b/docker-compose.yml
index 1efb1d4..03095be 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -5,9 +5,9 @@ services:
     build: .
     image: registry.alpha.grandlyon.com/refonte-data/admin-gui:${TAG}
     volumes: 
-      - ./nginx.conf.template:/etc/nginx/conf.d/default.conf
-      - ${CONFIG_FILE_PATH}:/usr/share/nginx/html/assets/config/config.json
+      - ${PWD}/nginx.conf.template:/etc/nginx/sites-enabled/default:ro
+      - ${CONFIG_FILE_PATH}:/usr/share/nginx/html/assets/config/config.json:ro
     ports: 
-      - ${APP_PORT}:80
+      - ${APP_PORT}:8080
     restart: unless-stopped 
-  
\ No newline at end of file
+  
diff --git a/nginx.conf.template b/nginx.conf.template
index 83591b0..d7ea65b 100644
--- a/nginx.conf.template
+++ b/nginx.conf.template
@@ -1,14 +1,16 @@
 server {
-    # staging server is listening on the port 8080
-    listen 80   ;
+    listen 8080;
     server_name _;
     root /usr/share/nginx/html/;
 
-    location /admin {
-        try_files $uri$args /index.html;
+    location /admin/ {
+        try_files $uri$args /admin/index.html;
+
     }
 
     location / {
-        ngx.redirect("/admin/")
-    }
+	rewrite_by_lua '
+		ngx.redirect("/admin/")
+	';
+   }
 }
-- 
GitLab