From f4c5db705e35ca42cf428b32a22f704cf61ea127 Mon Sep 17 00:00:00 2001 From: "guilhem.carron" <gcarron@grandlyon.com> Date: Thu, 12 Aug 2021 16:18:54 +0200 Subject: [PATCH] Add working local conf --- docker-compose.local.yml | 36 +++++++++++--------------------- nginx/site.conf | 36 +++++++++++++++++++++----------- package.json | 2 ++ src/components/Routes/Routes.tsx | 7 ++++++- src/react-app-env.d.ts | 1 + 5 files changed, 45 insertions(+), 37 deletions(-) create mode 100644 src/react-app-env.d.ts diff --git a/docker-compose.local.yml b/docker-compose.local.yml index 66b922b3..e6f47b60 100644 --- a/docker-compose.local.yml +++ b/docker-compose.local.yml @@ -1,35 +1,23 @@ version: '3.7' services: - nginx: - image: nginx:1.16 - restart: unless-stopped + front: + container_name: front + build: + context: . + dockerfile: Dockerfile + depends_on: + database: + condition: service_healthy volumes: - - ./nginx/site.conf:/etc/nginx/conf.d/default.conf + - '/app' + - '/app/node_modules' - ./nginx/nginx.conf:/etc/nginx/nginx.conf + - ./nginx/site.conf:/etc/nginx/conf.d/default.conf - ./cert.pem:/etc/nginx/cert.pem - ./key.pem:/etc/nginx/key.pem - command: ['nginx', '-g', 'daemon off;'] ports: - 8080:8080 - # depends_on: - # front: - # condition: service_healthy - links: - - front - - front: - image: bayesimpact/react-base - restart: unless-stopped - volumes: - - ./:/usr/app - working_dir: /usr/app - ports: - - 3000:3000 - healthcheck: - test: curl localhost:3000 - interval: 5s - timeout: 10s - retries: 60 + - 443:443 database: image: mysql:5 diff --git a/nginx/site.conf b/nginx/site.conf index c9798c4b..995197a2 100644 --- a/nginx/site.conf +++ b/nginx/site.conf @@ -1,15 +1,11 @@ server { - listen 8080 ; - server_name localhost; + listen 8080; + server_name local; location / { - proxy_pass https://front:3000; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection $http_connection; - proxy_set_header Host $host; - proxy_set_header X-Forwarded-Proto $scheme; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + 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,7 +19,23 @@ server { location /Logout { proxy_pass https://backend:1443/Logout; } - location /swagger { - proxy_pass https://backend:1443/swagger; - } + } + +server { + listen 443 ssl; + server_name local; + 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; + + location / { + proxy_pass http://localhost:8080; + } + location /OAuth2Callback { + proxy_pass https://backend:1443/OAuth2Callback; + } + + +} \ No newline at end of file diff --git a/package.json b/package.json index f5337a25..291c5b08 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,8 @@ "scripts": { "start": "react-scripts start", "build": "react-scripts build", + "docker-local-up" : "docker-compose -f docker-compose.local.yml up", + "docker-local-down" : "docker-compose -f docker-compose.local.yml down", "docker": "docker run -it --rm -p 3000:3000 front-backoffice", "lint": "eslint .", "lint:fix": "eslint --fix .", diff --git a/src/components/Routes/Routes.tsx b/src/components/Routes/Routes.tsx index a5c1b43a..266b9a11 100644 --- a/src/components/Routes/Routes.tsx +++ b/src/components/Routes/Routes.tsx @@ -11,7 +11,12 @@ const Routes: React.FC = () => { return ( <Switch> - {user && <Redirect path="/login" to="/editing" />} + {user && ( + <> + <Redirect path="/" to="/editing" /> + <Redirect path="/login" to="/editing" /> + </> + )} <Route path="/login" component={Login} /> <PrivateRoute path="/editing" component={Editing} exact /> <PrivateRoute path="/settings" component={Settings} exact /> diff --git a/src/react-app-env.d.ts b/src/react-app-env.d.ts new file mode 100644 index 00000000..6431bc5f --- /dev/null +++ b/src/react-app-env.d.ts @@ -0,0 +1 @@ +/// <reference types="react-scripts" /> -- GitLab