From 869192951610973163936d4f53b9deeaa4778db0 Mon Sep 17 00:00:00 2001 From: "a.bouhuolia" Date: Mon, 20 Sep 2021 23:12:04 +0200 Subject: [PATCH] feat: client docker build --- client/.dockerignore | 4 ++++ client/Dockerfile | 27 +++++++++++++++++++++++++++ client/nginx/nginx.conf | 20 ++++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 client/.dockerignore create mode 100644 client/Dockerfile create mode 100644 client/nginx/nginx.conf diff --git a/client/.dockerignore b/client/.dockerignore new file mode 100644 index 000000000..5bb840aea --- /dev/null +++ b/client/.dockerignore @@ -0,0 +1,4 @@ +node_modules +build + +.env* diff --git a/client/Dockerfile b/client/Dockerfile new file mode 100644 index 000000000..3ffbd19bf --- /dev/null +++ b/client/Dockerfile @@ -0,0 +1,27 @@ +FROM node:14.15.0 as build + +RUN apt-get update && \ + apt-get -y install sudo + +RUN useradd -m docker && echo "docker:docker" | chpasswd && adduser docker sudo + +USER docker + +ARG REACT_APP_SERVICES_HOST=/services/m + +WORKDIR /app + +COPY ./package.json /app/package.json +COPY ./package-lock.json /app/package-lock.json + +RUN npm install --loglevel verbose + +COPY . . + +RUN npm build + +FROM nginx + +COPY ./nginx/nginx.conf /etc/nginx/conf.d/default.conf + +COPY --from=build /app/build /usr/share/nginx/html diff --git a/client/nginx/nginx.conf b/client/nginx/nginx.conf new file mode 100644 index 000000000..9eb57dc8c --- /dev/null +++ b/client/nginx/nginx.conf @@ -0,0 +1,20 @@ +server { + listen 80; + server_name frontend; + location / { + # This would be the directory where your React app's static files are stored at + root /usr/share/nginx/html; + try_files $uri /index.html; + } + + location /services/m { + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-NginX-Proxy true; + proxy_pass http://backend:8080/services/m; + proxy_ssl_session_reuse off; + proxy_set_header Host $http_host; + proxy_cache_bypass $http_upgrade; + proxy_redirect off; + } +}