diff --git a/docker-compose.yml b/docker-compose.yml index 084e1416d..c9b84fac3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -172,10 +172,12 @@ services: ui: restart: unless-stopped - image: ${DOCKER_REG}/ui:${TAG:-1} + image: ${DOCKER_REG}/ui:${TAG:} environment: - 'SPRING_PROFILES_ACTIVE=prod' + - OAUTH2_WEB_CLIENT_CONFIGURATION_SECRET=${WEB_CLIENT_CONFIGURATION_SECRET} + - GATEWAY_COOKIE_DOMAIN=${COOKIE_DOMAIN} volumes: - ${LOG_VOLUME:-/var/tmp/}:/logs ports: - - 4200:4200 + - 8090:8090 diff --git a/ui/Dockerfile b/ui/Dockerfile index 48ddb0e98..d1ae9bfdc 100644 --- a/ui/Dockerfile +++ b/ui/Dockerfile @@ -1,4 +1,4 @@ -FROM node:20.7.0-bullseye-slim +FROM node:20.7.0-bullseye-slim AS ui-build-stage # Create app directory WORKDIR /app @@ -6,7 +6,7 @@ WORKDIR /app # Install some useful utils for debug/test RUN \ apt-get update && \ - apt -y install procps iproute2 net-tools curl iputils-ping vim && \ + apt -y install python3 make gcc g++ && \ rm -rf /var/lib/apt/lists/* # Install app dependencies @@ -14,20 +14,28 @@ RUN \ # where available (npm@5+) COPY package*.json ./ -COPY container-files/* /var/tmp/ - -RUN \ - chmod +x /var/tmp/* && \ - npm install - # If you are building your code for production # RUN npm install --only=production +RUN npm install # Bundle app source COPY . . RUN npm run build -EXPOSE 4200 +FROM nginx + +RUN \ + apt-get update && \ + apt -y install procps vim && \ + rm -rf /var/lib/apt/lists/* + +COPY container-files/etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf + +# Copy files from the ui-build-stage into this new nginx stage +COPY --from=ui-build-stage /app/dist/ /usr/share/nginx/html/ + +EXPOSE 8090 -ENTRYPOINT /var/tmp/entrypoint.sh +# Use the underlying ENTRYPOINT and CMD provided by the base NGINX image +#ENTRYPOINT /var/tmp/entrypoint.sh diff --git a/ui/angular.json b/ui/angular.json index d9e6c11c0..a07983c60 100644 --- a/ui/angular.json +++ b/ui/angular.json @@ -17,7 +17,7 @@ "build": { "builder": "@angular-devkit/build-angular:browser", "options": { - "outputPath": "dist/ui", + "outputPath": "dist/", "index": "src/index.html", "main": "src/main.ts", "polyfills": "src/polyfills.ts", diff --git a/ui/container-files/entrypoint.sh b/ui/container-files/entrypoint.sh deleted file mode 100644 index f93b1d9a2..000000000 --- a/ui/container-files/entrypoint.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash - -# The NPM "start" command/script is defined in the package.json file in the "scripts" dict -npm start diff --git a/ui/container-files/etc/nginx/conf.d/default.conf b/ui/container-files/etc/nginx/conf.d/default.conf new file mode 100644 index 000000000..f61676a2f --- /dev/null +++ b/ui/container-files/etc/nginx/conf.d/default.conf @@ -0,0 +1,24 @@ +server { + listen 8090; + server_name localhost; + + #access_log /var/log/nginx/host.access.log main; + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + rewrite ^/ui/(.*) /$1 break; + } + + # JT. Uncomment the error_page directive below to use the orcid 404 error page in /404 + #error_page 404 ../404; + + # redirect server error pages to the static page /50x.html + # + #error_page 500 502 503 504 /50x.html; + #location = /50x.html { + # root /usr/share/nginx/html; + #} + +} + diff --git a/ui/container-files/etc/nginx/nginx.conf b/ui/container-files/etc/nginx/nginx.conf new file mode 100644 index 000000000..ee8c7fd6b --- /dev/null +++ b/ui/container-files/etc/nginx/nginx.conf @@ -0,0 +1,31 @@ +user nginx; +worker_processes auto; + +error_log /var/log/nginx/error.log notice; +pid /var/run/nginx.pid; + + +events { + worker_connections 1024; +} + + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; + + sendfile on; + #tcp_nopush on; + + keepalive_timeout 65; + + #gzip on; + + include /etc/nginx/conf.d/*.conf; +} \ No newline at end of file