Dockerize the frontend of controlpanel 98/5398/4
authorRehanRaza <muhammad.rehan.raza@est.tech>
Fri, 8 Jan 2021 16:54:16 +0000 (17:54 +0100)
committerRehanRaza <muhammad.rehan.raza@est.tech>
Tue, 12 Jan 2021 12:35:13 +0000 (13:35 +0100)
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 <muhammad.rehan.raza@est.tech>
pom.xml
webapp-backend/pom.xml
webapp-frontend/.dockerignore [new file with mode: 0644]
webapp-frontend/Dockerfile [new file with mode: 0644]
webapp-frontend/container-tag.yaml [new file with mode: 0644]
webapp-frontend/nginx.conf [new file with mode: 0644]
webapp-frontend/pom.xml [deleted file]

diff --git a/pom.xml b/pom.xml
index f3bae57..dccfe22 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -40,7 +40,6 @@ limitations under the License.
         <sonar-maven-plugin.version>3.7.0.1746</sonar-maven-plugin.version>
        </properties>
        <modules>
-               <module>webapp-frontend</module>
                <module>webapp-backend</module>
        </modules>
        <build>
index fc4ec39..d49b53b 100644 (file)
@@ -219,26 +219,6 @@ limitations under the License.
                     </archive>
                 </configuration>
             </plugin>
-            <plugin>
-                <artifactId>maven-resources-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <id>copy-resources</id>
-                        <phase>validate</phase>
-                        <goals>
-                            <goal>copy-resources</goal>
-                        </goals>
-                        <configuration>
-                            <outputDirectory>${project.build.directory}/classes/resources/</outputDirectory>
-                            <resources>
-                                <resource>
-                                    <directory>${project.parent.basedir}/webapp-frontend/dist/controlpanelApp/</directory>
-                                </resource>
-                            </resources>
-                        </configuration>
-                    </execution>
-                </executions>
-            </plugin>
             <!-- do not deploy a jar or pom file -->
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
@@ -281,7 +261,7 @@ limitations under the License.
                         <image>
                             <!-- Specify a tag to avoid default tag "latest" -->
                             <!-- Avoid maven artifact name here -->
-                            <name>o-ran-sc/nonrtric-controlpanel:${project.version}</name>
+                            <name>o-ran-sc/nonrtric-controlpanel-backend:${project.version}</name>
                             <build>
                                 <from>openjdk:11-jre-slim</from>
                                 <tags>
diff --git a/webapp-frontend/.dockerignore b/webapp-frontend/.dockerignore
new file mode 100644 (file)
index 0000000..1521c8b
--- /dev/null
@@ -0,0 +1 @@
+dist
diff --git a/webapp-frontend/Dockerfile b/webapp-frontend/Dockerfile
new file mode 100644 (file)
index 0000000..c711e47
--- /dev/null
@@ -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 (file)
index 0000000..46ba559
--- /dev/null
@@ -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 (file)
index 0000000..47d7b26
--- /dev/null
@@ -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 (file)
index f3a1077..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--<![CDATA[
-========================LICENSE_START=================================
-O-RAN-SC
-%%
-Copyright (C) 2019 AT&T Intellectual Property
-Modifications Copyright (C) 2020 Nordix Foundation
-%%
-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===================================
-]]>-->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-       <modelVersion>4.0.0</modelVersion>
-       <parent>
-               <groupId>org.o-ran-sc.portal.nonrtric.controlpanel</groupId>
-               <artifactId>nonrtric-controlpanel-parent</artifactId>
-               <version>2.2.0-SNAPSHOT</version>
-       </parent>
-       <artifactId>nonrtric-controlpanel-fe</artifactId>
-       <name>Non-RT RIC Control Panel Webapp frontend</name>
-       <build>
-               <plugins>
-                       <plugin>
-                               <groupId>com.github.eirslett</groupId>
-                               <artifactId>frontend-maven-plugin</artifactId>
-                               <version>1.3</version>
-                               <configuration>
-                                       <nodeVersion>v10.15.3</nodeVersion>
-                                       <npmVersion>6.7.0</npmVersion>
-                                       <workingDirectory>.</workingDirectory>
-                               </configuration>
-                               <executions>
-                                       <execution>
-                                               <id>install node and npm</id>
-                                               <goals>
-                                                       <goal>install-node-and-npm</goal>
-                                               </goals>
-                                       </execution>
-                                       <execution>
-                                               <id>npm install</id>
-                                               <goals>
-                                                       <goal>npm</goal>
-                                               </goals>
-                                       </execution>
-                                       <execution>
-                                               <id>npm run build</id>
-                                               <goals>
-                                                       <goal>npm</goal>
-                                               </goals>
-                                               <configuration>
-                                                       <arguments>run build</arguments>
-                                               </configuration>
-                                       </execution>
-                                       <execution>
-                                               <id>prod</id>
-                                               <goals>
-                                                       <goal>npm</goal>
-                                               </goals>
-                                               <configuration>
-                                                       <arguments>run-script build</arguments>
-                                               </configuration>
-                                               <phase>generate-resources</phase>
-                                       </execution>
-                               </executions>
-                       </plugin>
-                       <plugin>
-                               <groupId>org.apache.maven.plugins</groupId>
-                               <artifactId>maven-clean-plugin</artifactId>
-                               <configuration>
-                                       <filesets>
-                                               <fileset>
-                                                       <directory>${project.basedir}</directory>
-                                                       <includes>
-                                                               <include>**/node_modules/**</include>
-                                                               <include>dist/**</include>
-                                                               <include>node/**</include>
-                                                       </includes>
-                                                       <followSymlinks>false</followSymlinks>
-                                               </fileset>
-                                               <fileset>
-                                                       <directory>node</directory>
-                                               </fileset>
-                                       </filesets>
-                               </configuration>
-                       </plugin>
-               </plugins>
-       </build>
-</project>