From f9523c1537c94946ecd9a8250b0de429881418f5 Mon Sep 17 00:00:00 2001 From: RehanRaza Date: Fri, 8 Jan 2021 17:54:16 +0100 Subject: [PATCH] Dockerize the frontend of controlpanel Enable the frontend to run in its own docker container, and make calls to the configurable backend. Change-Id: Ie9eebf5c1ea144feea8c3cd0d9c21a6ac892d9c2 Issue-ID: NONRTRIC-376 Signed-off-by: RehanRaza --- pom.xml | 1 - webapp-backend/pom.xml | 22 +------- webapp-frontend/.dockerignore | 1 + webapp-frontend/Dockerfile | 28 +++++++++++ webapp-frontend/container-tag.yaml | 2 + webapp-frontend/nginx.conf | 20 ++++++++ webapp-frontend/pom.xml | 100 ------------------------------------- 7 files changed, 52 insertions(+), 122 deletions(-) create mode 100644 webapp-frontend/.dockerignore create mode 100644 webapp-frontend/Dockerfile create mode 100644 webapp-frontend/container-tag.yaml create mode 100644 webapp-frontend/nginx.conf delete mode 100644 webapp-frontend/pom.xml diff --git a/pom.xml b/pom.xml index f3bae57..dccfe22 100644 --- a/pom.xml +++ b/pom.xml @@ -40,7 +40,6 @@ limitations under the License. 3.7.0.1746 - webapp-frontend webapp-backend diff --git a/webapp-backend/pom.xml b/webapp-backend/pom.xml index fc4ec39..d49b53b 100644 --- a/webapp-backend/pom.xml +++ b/webapp-backend/pom.xml @@ -219,26 +219,6 @@ limitations under the License. - - maven-resources-plugin - - - copy-resources - validate - - copy-resources - - - ${project.build.directory}/classes/resources/ - - - ${project.parent.basedir}/webapp-frontend/dist/controlpanelApp/ - - - - - - org.apache.maven.plugins @@ -281,7 +261,7 @@ limitations under the License. - o-ran-sc/nonrtric-controlpanel:${project.version} + o-ran-sc/nonrtric-controlpanel-backend:${project.version} openjdk:11-jre-slim diff --git a/webapp-frontend/.dockerignore b/webapp-frontend/.dockerignore new file mode 100644 index 0000000..1521c8b --- /dev/null +++ b/webapp-frontend/.dockerignore @@ -0,0 +1 @@ +dist diff --git a/webapp-frontend/Dockerfile b/webapp-frontend/Dockerfile new file mode 100644 index 0000000..c711e47 --- /dev/null +++ b/webapp-frontend/Dockerfile @@ -0,0 +1,28 @@ +# ============LICENSE_START=============================================== +# Copyright (C) 2020 Nordix Foundation. All rights reserved. +# ======================================================================== +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END================================================= +# +### STAGE 1: Build App ### +FROM node:14-alpine AS stage1 +WORKDIR /usr/src/app +COPY package*.json ./ +RUN npm install +COPY . . +RUN npm run-script build + +### STAGE 2: Run App ### +FROM nginx:alpine +COPY nginx.conf /etc/nginx/nginx.conf +COPY --from=stage1 /usr/src/app/dist/controlpanelApp /usr/share/nginx/html \ No newline at end of file diff --git a/webapp-frontend/container-tag.yaml b/webapp-frontend/container-tag.yaml new file mode 100644 index 0000000..46ba559 --- /dev/null +++ b/webapp-frontend/container-tag.yaml @@ -0,0 +1,2 @@ +--- +tag: 2.2.0-SNAPSHOT diff --git a/webapp-frontend/nginx.conf b/webapp-frontend/nginx.conf new file mode 100644 index 0000000..47d7b26 --- /dev/null +++ b/webapp-frontend/nginx.conf @@ -0,0 +1,20 @@ +events{} + +http { + include /etc/nginx/mime.types; + + upstream backend { + # to be replaced with hostname:port of nonrtric-gateway once it gets ready + server controlpanel-backend-container:8080; + } + + server { + listen 7070; + server_name localhost; + root /usr/share/nginx/html; + index index.html; + location /api/ { + proxy_pass http://backend; + } + } +} \ No newline at end of file diff --git a/webapp-frontend/pom.xml b/webapp-frontend/pom.xml deleted file mode 100644 index f3a1077..0000000 --- a/webapp-frontend/pom.xml +++ /dev/null @@ -1,100 +0,0 @@ - - - - 4.0.0 - - org.o-ran-sc.portal.nonrtric.controlpanel - nonrtric-controlpanel-parent - 2.2.0-SNAPSHOT - - nonrtric-controlpanel-fe - Non-RT RIC Control Panel Webapp frontend - - - - com.github.eirslett - frontend-maven-plugin - 1.3 - - v10.15.3 - 6.7.0 - . - - - - install node and npm - - install-node-and-npm - - - - npm install - - npm - - - - npm run build - - npm - - - run build - - - - prod - - npm - - - run-script build - - generate-resources - - - - - org.apache.maven.plugins - maven-clean-plugin - - - - ${project.basedir} - - **/node_modules/** - dist/** - node/** - - false - - - node - - - - - - - -- 2.16.6