Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/mserve UI container add nginx #1053

Merged
merged 9 commits into from
Nov 2, 2023
6 changes: 4 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
28 changes: 18 additions & 10 deletions ui/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,33 +1,41 @@
FROM node:20.7.0-bullseye-slim
FROM node:20.7.0-bullseye-slim AS ui-build-stage

# Create app directory
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
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# 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
2 changes: 1 addition & 1 deletion ui/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 0 additions & 4 deletions ui/container-files/entrypoint.sh

This file was deleted.

24 changes: 24 additions & 0 deletions ui/container-files/etc/nginx/conf.d/default.conf
Original file line number Diff line number Diff line change
@@ -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;
#}

}

31 changes: 31 additions & 0 deletions ui/container-files/etc/nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -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;
}
Loading