From 3a6b22c7c234c68588f654bd419737d0903d4466 Mon Sep 17 00:00:00 2001
From: "guilhem.carron" <gcarron@grandlyon.com>
Date: Tue, 21 Sep 2021 15:12:09 +0200
Subject: [PATCH] Update Readme + prod conf files

---
 README.md            | 10 ++++++++++
 docker-compose.yml   | 24 ++++++++++++++----------
 nginx/site.prod.conf | 24 ++++++++++++++++++------
 3 files changed, 42 insertions(+), 16 deletions(-)

diff --git a/README.md b/README.md
index 9b0c93ba..5546d2b2 100644
--- a/README.md
+++ b/README.md
@@ -44,6 +44,8 @@ This app runs in https, such as the backend, to access it go on https://localhos
 Also make sure you have HTTPS env variable set to true.
 Do not use the app with the port 3000, you won't be able to login.
 
+> :warning: **If you are launching the project from a Linux OS** : Make sure to uncomment the commented lines in the docker-compose.local file. Otherwise, you you won't be able to access your machine's localhost from the docker container.
+
 ## Backend and Database
 
 In order to get Backend documentation, please refer directly to the [backend project](https://forge.grandlyon.com/web-et-numerique/llle_project/backoffice-server)
@@ -69,3 +71,11 @@ On dev and master branches, the pipeline will run a docker image build that you
 
 This app uses Draft.js Wysiwyg editor for more information checkout its (documentation page)[https://draftjs.org/docs/getting-started]
 For more advanced documentation about editor customization, please checkout the (react draft wysiwig page)[https://jpuri.github.io/react-draft-wysiwyg/#/docs?_k=jjqinp]
+
+### Environment Variables
+
+There is a template.env file in this project, however you can ask one the developpers to get a ready-to-use .env file.
+
+- IMAGE_FOLDER: this variable specify the folder where ecogestures images are located. By default, you can place this folder at the same level as your project for a local usage. (not inside the project). For alpha, rec/prod environment, make sure the path indicated in docker-compose volumes correspond with the location of the image file on the server.
+
+- MOCK_OAUTH2: Set this variable to true while in local, so the OAuth2 dance will be mocked by backend and you will be able to login to your application.
diff --git a/docker-compose.yml b/docker-compose.yml
index 8d2d1b3c..86d3e525 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -4,21 +4,23 @@ services:
     image: registry.forge.grandlyon.com/web-et-numerique/llle_project/backoffice-client:dev
     restart: unless-stopped
     ports:
-      - 443:443
+      - 8088:8080
+    depends_on:
+      - backend
     networks:
       backoffice:
     volumes:
-      - ./nginx/site.prod.conf:/etc/nginx/conf.d/default.conf
-      - ./nginx/nginx.conf:/etc/nginx/nginx.conf
-      - ./cert.pem:/etc/nginx/cert.pem
-      - ./key.pem:/etc/nginx/key.pem
+      - ./site.conf:/etc/nginx/conf.d/default.conf
+      - ./image-lib:/usr/share/nginx/html/lib
+      - ./dacc-preview:/usr/share/nginx/html/static-site
 
-  database:
+  database-agent:
     image: mysql:5
     ports:
       - 3306:3306
     networks:
       backoffice:
+    restart: unless-stopped
     environment:
       MYSQL_ROOT_PASSWORD: ${DATABASE_PASSWORD}
       MYSQL_DATABASE: ${DATABASE_NAME}
@@ -33,7 +35,7 @@ services:
     networks:
       backoffice:
     depends_on:
-      database:
+      database-agent:
         condition: service_healthy
     restart: unless-stopped
     volumes:
@@ -41,9 +43,10 @@ services:
       - ./configs:/app/configs
       - ./letsencrypt_cache:/app/letsencrypt_cache
       - ./data:/app/data
+      - ./image-lib/${IMAGE_FOLDER}:/app/${IMAGE_FOLDER}
     ports:
       - ${HTTPS_PORT}:${HTTPS_PORT}
-      - 8090:8090
+      - 8190:8090
     environment:
       - HOSTNAME=${HOSTNAME}
       - HTTPS_PORT=${HTTPS_PORT}
@@ -52,14 +55,15 @@ services:
       - CLIENT_ID=${CLIENT_ID}
       - CLIENT_SECRET=${CLIENT_SECRET}
       - AUTH_URL=${AUTH_URL}
+      - IMAGE_FOLDER=${IMAGE_FOLDER}
+      - MOCK_OAUTH2=${MOCK_OAUTH2}
       - TOKEN_URL=${TOKEN_URL}
       - USERINFO_URL=${USERINFO_URL}
       - DEBUG_MODE=${DEBUG_MODE}
-      - MOCK_OAUTH2=${MOCK_OAUTH2}
       - DATABASE_USER=${DATABASE_USER}
       - DATABASE_NAME=${DATABASE_NAME}
       - DATABASE_PASSWORD=${DATABASE_PASSWORD}
-      - DATABASE_HOST=database
+      - DATABASE_HOST=database-agent
 
 networks:
   backoffice:
diff --git a/nginx/site.prod.conf b/nginx/site.prod.conf
index e6d27c77..e9fdd62d 100644
--- a/nginx/site.prod.conf
+++ b/nginx/site.prod.conf
@@ -1,16 +1,13 @@
 server {
-        listen 443 ssl;
-        server_name         localhost;
-        ssl_certificate     /etc/nginx/cert.pem;
-        ssl_certificate_key /etc/nginx/key.pem;
-        ssl_protocols       TLSv1 TLSv1.1 TLSv1.2;
-        ssl_ciphers         HIGH:!aNULL:!MD5;
+        listen 8080;
+        server_name         ecolyo-agent.self-data.alpha.grandlyon.com;
 
         location / {
             root /usr/share/nginx/html;
             index index.html index.htm;
             try_files $uri $uri/ /index.html =404;
         }
+        
         location /api {  
             proxy_pass https://backend:1443/api;
         }
@@ -23,4 +20,19 @@ server {
         location /Logout {
             proxy_pass https://backend:1443/Logout;
         }
+        location /swagger {
+            proxy_pass https://backend:1443/swagger;
+        }
+        location /imageNames {
+            proxy_pass https://backend:1443/api/admin/imageNames;
+        }
+        
+        location ~ ^/assets/(.+\.(?:gif|jpe?g|svg))$  {
+          alias /usr/share/nginx/html/lib/$1;
+          gzip_static on;
+          expires max;
+          add_header Cache-Control public;
+        }
+        
 }
+
-- 
GitLab