Browse Source

Adding deployment

bodicsek 3 years ago
parent
commit
14e3cef195

+ 3 - 3
Dockerfile

@@ -10,8 +10,8 @@ COPY . .
 
 RUN npm ci
 
-EXPOSE 8000
+EXPOSE 8001
 
-ENV appName "Plugin A"
+ENV APP_NAME "Plugin A"
 
-CMD [ "npm", "run", "start" ]
+CMD [ "npm", "run", "start" ]

+ 23 - 0
deployment/helm-chart/.helmignore

@@ -0,0 +1,23 @@
+# Patterns to ignore when building packages.
+# This supports shell glob matching, relative path matching, and
+# negation (prefixed with !). Only one pattern per line.
+.DS_Store
+# Common VCS dirs
+.git/
+.gitignore
+.bzr/
+.bzrignore
+.hg/
+.hgignore
+.svn/
+# Common backup files
+*.swp
+*.bak
+*.tmp
+*.orig
+*~
+# Various IDEs
+.project
+.idea/
+*.tmproj
+.vscode/

+ 24 - 0
deployment/helm-chart/Chart.yaml

@@ -0,0 +1,24 @@
+apiVersion: v2
+name: occ-fw-ui
+description: A Helm chart for Kubernetes
+
+# A chart can be either an 'application' or a 'library' chart.
+#
+# Application charts are a collection of templates that can be packaged into versioned archives
+# to be deployed.
+#
+# Library charts provide useful utilities or functions for the chart developer. They're included as
+# a dependency of application charts to inject those utilities and functions into the rendering
+# pipeline. Library charts do not define any templates and therefore cannot be deployed.
+type: application
+
+# This is the chart version. This version number should be incremented each time you make changes
+# to the chart and its templates, including the app version.
+# Versions are expected to follow Semantic Versioning (https://semver.org/)
+version: 0.1.0
+
+# This is the version number of the application being deployed. This version number should be
+# incremented each time you make changes to the application. Versions are not expected to
+# follow Semantic Versioning. They should reflect the version the application is using.
+# It is recommended to use it with quotes.
+appVersion: "1.16.0"

+ 25 - 0
deployment/helm-chart/templates/deployment.yaml

@@ -0,0 +1,25 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  name: {{ .Values.appName }}-deployment
+spec:
+  selector:
+    matchLabels:
+      app: {{ .Values.appName }}
+  replicas: 1
+  template:
+    metadata:
+      labels:
+        app: {{ .Values.appName }}
+    spec:
+      containers:
+        - name: {{ .Values.appName }}
+          image: {{ .Values.imageRegistry }}/{{ .Values.imageName }}:{{ .Values.appVersion }}
+          imagePullPolicy: Always
+          env:
+            - name: APP_NAME
+              value: {{ .Values.appNameLabel }}
+          ports:
+          - containerPort: 8001
+      imagePullSecrets:
+        - name: {{ .Values.imagePullSecret }}

+ 15 - 0
deployment/helm-chart/templates/ingress.yaml

@@ -0,0 +1,15 @@
+apiVersion: traefik.containo.us/v1alpha1
+kind: IngressRoute
+metadata:
+  name: {{ .Values.appName }}-ingress-route
+spec:
+  entryPoints:
+    - websecure
+  tls: {}
+  routes:
+    - kind: Rule
+      match: Host(`{{ .Values.host }}`)
+      services:
+        - kind: Service
+          name: {{ .Values.appName }}-service
+          port: 80

+ 11 - 0
deployment/helm-chart/templates/service.yaml

@@ -0,0 +1,11 @@
+apiVersion: v1
+kind: Service
+metadata:
+  name: {{ .Values.appName }}-service
+spec:
+  selector:
+    app: {{ .Values.appName }}
+  ports:
+    - protocol: TCP
+      port: 80
+      targetPort: 8001

+ 11 - 0
deployment/helm-chart/values.yaml

@@ -0,0 +1,11 @@
+# Default values for helm-chart.
+# This is a YAML-formatted file.
+# Declare variables to be passed into your templates.
+
+appName: occ-fw-plugin-a
+appVersion: 1.0.0
+appNameLabel: Plugin A
+imageRegistry: iad.ocir.io/cesdev
+imageName: occ-fw-plugin-a
+imagePullSecret: ocirsecret
+host: customercentral-plugin-a.oracle.com

+ 7 - 0
deployment/scripts/ocir-login.sh

@@ -0,0 +1,7 @@
+#!/bin/sh
+
+readarray -d / -t registry <<< $1
+
+oci --profile DEFAULT raw-request --http-method GET --target-uri https://$registry/20180419/docker/token \
+| jq -r '.data.token' \
+| docker login -u BEARER_TOKEN --password-stdin iad.ocir.io

+ 9 - 3
ojet.config.js

@@ -5,6 +5,7 @@
 
 */
 const webpack = require("webpack");
+const package = require("./package.json");
 
 module.exports = {
   /**
@@ -24,11 +25,16 @@ module.exports = {
       // update config with development options
       config.devServer = {
         ...config.devServer,
-        https: true,
-        port: 8001
+        https: process.env.HTTPS === "true",
+        port: 8001,
+        allowedHosts: [
+          "localhost",
+          package.config.hostPluginA,
+          package.config.hostDashboard
+        ]
       };
       config.plugins.push(new webpack.DefinePlugin({
-        APP_NAME: JSON.stringify(process.env.appName)
+        APP_NAME: JSON.stringify(process.env.APP_NAME)
       }));
     }
     // only have to return if new config object was created but

File diff suppressed because it is too large
+ 272 - 278
package-lock.json


+ 14 - 5
package.json

@@ -1,13 +1,19 @@
 {
-  "name": "idcs-plugin-a",
-  "version": "1.0.0",
+  "name": "occ-fw-plugin-a",
+  "version": "1.0.2",
   "description": "An Oracle JavaScript Extension Toolkit(JET) web app",
   "config": {
-    "host": "customercentral-dashboard.oracle.com",
-    "registry": "iad.ocir.io/cesdev"
+    "registry": "iad.ocir.io/cesdev",
+    "hostPluginA": "customercentral-plugin-a.oracle.com",
+    "hostDashboard": "customercentral-dashboard.oracle.com"
   },
   "scripts": {
-    "build:container": "docker build -t $npm_package_config_registry/$npm_package_name:$npm_package_version ."
+    "env": "env",
+    "start": "DEBUG='express:*' ojet serve",
+    "build:container": "docker build -t $npm_package_config_registry/$npm_package_name:$npm_package_version .",
+    "deploy:container": "npm run build:container && ./deployment/scripts/ocir-login.sh $npm_package_config_registry && docker push $npm_package_config_registry/$npm_package_name:$npm_package_version",
+    "deploy:plugin-a": "npm run deploy:container && helm upgrade --install $npm_package_name --set appName=$npm_package_name --set appVersion=$npm_package_version --set host=$npm_package_config_hostPluginA --set imageRegistry=$npm_package_config_registry ./deployment/helm-chart",
+    "deploy:dashboard": "npm run deploy:container && helm upgrade --install occ-fw-dashboard --set appName=occ-fw-dashboard --set appVersion=$npm_package_version --set appNameLabel=Dashboard --set host=$npm_package_config_hostDashboard --set imageRegistry=$npm_package_config_registry ./deployment/helm-chart"
   },
   "dependencies": {
     "@oracle/oraclejet": "~13.0.0"
@@ -37,6 +43,9 @@
     "webpack-merge": "5.8.0",
     "yargs-parser": "13.1.2"
   },
+  "overrides": {
+    "preact": "10.7.2"
+  },
   "engines": {
     "node": ">=16"
   },

+ 1 - 1
src/hooks/useLogin.tsx

@@ -23,7 +23,7 @@ const login = () => {
   window.location.href = `${idcsStripe}/oauth2/v1/authorize` +
     `?client_id=${clientId}` +
     "&response_type=code" +
-    "&redirect_uri=https%3A%2F%2Flocalhost%3A8001" +
+    `&redirect_uri=${encodeURIComponent(window.location.href)}` +
     "&scope=openid" +
     `&nonce=${nonce}` +
     `&state=${state}`;

Some files were not shown because too many files changed in this diff