From 0f77e5ea3b046667c627822bb3a47c5ce9623601 Mon Sep 17 00:00:00 2001 From: Andrew Kapuscinski <akapusci@nrao.edu> Date: Thu, 25 Feb 2021 12:50:56 -0700 Subject: [PATCH] nginx will now serve our UI instead of the ng development server --- apps/web/Dockerfile.dev | 27 +++++++++++++++++++++++++-- apps/web/ws-nginx.conf | 17 +++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 apps/web/ws-nginx.conf diff --git a/apps/web/Dockerfile.dev b/apps/web/Dockerfile.dev index a7928ec1e..38d21ed28 100644 --- a/apps/web/Dockerfile.dev +++ b/apps/web/Dockerfile.dev @@ -1,4 +1,6 @@ -FROM marconi.aoc.nrao.edu/ops/base:nodejs-14 +FROM marconi.aoc.nrao.edu/ops/base:nodejs-14 as base-build + +# TODO: install chrome dependencies for e2e test here WORKDIR /app @@ -12,4 +14,25 @@ RUN npm install \ COPY ./apps/web ./ -CMD [ "npm", "start" ] \ No newline at end of file +# TODO: Run e2e tests here + +# Build the angular app +RUN ./node_modules/.bin/ng build --prod --output-path=dist + +# Use nginx base image +FROM nginx:1.19.7-alpine + +# Copy WS nginx config from base-build stage +COPY --from=base-build /app/ws-nginx.conf /etc/nginx/conf.d/ + +# Remove default nginx config +RUN rm /etc/nginx/conf.d/default.conf + +# Copy Angular build from base-build stage +COPY --from=base-build /app/dist /usr/share/nginx/html + +# Expose port +EXPOSE 4444 + +# Run nginx with daemon off to run as foreground process +CMD nginx -g "daemon off;" \ No newline at end of file diff --git a/apps/web/ws-nginx.conf b/apps/web/ws-nginx.conf new file mode 100644 index 000000000..db7088fd6 --- /dev/null +++ b/apps/web/ws-nginx.conf @@ -0,0 +1,17 @@ +# Workspaces NGINX config +server { + listen 80; + listen [::]:80; + server_name localhost; + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + try_files $uri $uri/ /index.html; + } + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } +} \ No newline at end of file -- GitLab