From ba2768221f12b1130a0965e8d84391c4d4ce1ca9 Mon Sep 17 00:00:00 2001 From: ddelpiano Date: Thu, 21 Mar 2024 19:39:07 +0100 Subject: [PATCH 1/2] Fixing build and mispelled variables --- src/components/common/CommonChip.tsx | 4 ++-- .../graphDiagram/widgets/DestinationNodeWidget.tsx | 7 ++----- src/components/graphDiagram/widgets/ViaNodeWidget.tsx | 6 +++--- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/components/common/CommonChip.tsx b/src/components/common/CommonChip.tsx index ebdb5e5..fa920de 100644 --- a/src/components/common/CommonChip.tsx +++ b/src/components/common/CommonChip.tsx @@ -2,7 +2,7 @@ import React from 'react'; import Chip, { ChipProps } from '@mui/material/Chip'; import {vars} from "../../theme/variables.ts"; -const { primarypurple500 } = vars +const { primaryPurple500 } = vars interface CommonChipProps extends ChipProps {} @@ -16,7 +16,7 @@ const CommonChip: React.FC = ({ label, variant = "outlined", ic sx={{ '& .MuiSvgIcon-root': { order: 1, - color: primarypurple500 + color: primaryPurple500 } }} /> diff --git a/src/components/graphDiagram/widgets/DestinationNodeWidget.tsx b/src/components/graphDiagram/widgets/DestinationNodeWidget.tsx index 27e4ea3..ca8c5d7 100644 --- a/src/components/graphDiagram/widgets/DestinationNodeWidget.tsx +++ b/src/components/graphDiagram/widgets/DestinationNodeWidget.tsx @@ -15,10 +15,7 @@ interface DestinationNodeProps { engine: DiagramEngine; } -export const DestinationNodeWidget: React.FC = ({ - model, - engine, - }) => { +export const DestinationNodeWidget: React.FC = ({model, engine}) => { // State to toggle the color const [isActive, setIsActive] = useState(false); const [zIndex, setZIndex] = useState(0); @@ -190,7 +187,7 @@ export const DestinationNodeWidget: React.FC = ({ "& .MuiChip-deleteIcon": { fontSize: "14px", - color: vars.mediumBlue, + color: vars.primaryBlue500, }, }} /> diff --git a/src/components/graphDiagram/widgets/ViaNodeWidget.tsx b/src/components/graphDiagram/widgets/ViaNodeWidget.tsx index 04b3a47..2304577 100644 --- a/src/components/graphDiagram/widgets/ViaNodeWidget.tsx +++ b/src/components/graphDiagram/widgets/ViaNodeWidget.tsx @@ -183,14 +183,14 @@ export const ViaNodeWidget: React.FC = ({model, engine}) => { label={model.getOptions().anatomicalType} variant="filled" sx={{ - background: vars.lightBlue, - color: vars.darkBlue, + background: vars.primaryBlue300, + color: vars.primaryBlue800, marginLeft: "10px", marginRight: "10px", "& .MuiChip-deleteIcon": { fontSize: "14px", - color: vars.mediumBlue, + color: vars.primaryBlue500, }, }} /> From b1022a4eeb8b2a2001ecf0b8123926179ad67f55 Mon Sep 17 00:00:00 2001 From: ddelpiano Date: Fri, 22 Mar 2024 11:41:20 +0100 Subject: [PATCH 2/2] deployment --- Dockerfile | 24 ++++++++++++++ deploy/codefresh/codefresh.yml | 35 +++++++++++++++++++++ deploy/k8s/codefresh.yaml | 34 ++++++++++++++++++++ deploy/k8s/deploy.sh | 21 +++++++++++++ deploy/k8s/deploy_minikube.sh | 9 ++++++ deploy/k8s/ingress.yaml | 39 +++++++++++++++++++++++ deploy/k8s/sckanner.yaml | 57 ++++++++++++++++++++++++++++++++++ nginx/default.bak | 32 +++++++++++++++++++ nginx/default.conf | 32 +++++++++++++++++++ 9 files changed, 283 insertions(+) create mode 100644 Dockerfile create mode 100644 deploy/codefresh/codefresh.yml create mode 100644 deploy/k8s/codefresh.yaml create mode 100755 deploy/k8s/deploy.sh create mode 100755 deploy/k8s/deploy_minikube.sh create mode 100644 deploy/k8s/ingress.yaml create mode 100644 deploy/k8s/sckanner.yaml create mode 100644 nginx/default.bak create mode 100644 nginx/default.conf diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..5a534d0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +ARG NODE_PARENT=node:18 + +FROM ${NODE_PARENT} as frontend + +ENV BUILDDIR=/app + +WORKDIR ${BUILDDIR} +COPY package.json ${BUILDDIR} +COPY yarn.lock ${BUILDDIR} +COPY nginx/default.conf ${BUILDDIR} + +RUN yarn install +COPY . ${BUILDDIR} +RUN yarn build + +FROM nginx:1.19.3-alpine + +RUN cat /etc/nginx/conf.d/default.conf + +COPY --from=frontend /app/default.conf /etc/nginx/conf.d/default.conf + +COPY --from=frontend /app/dist /usr/share/nginx/html/ + +EXPOSE 80 diff --git a/deploy/codefresh/codefresh.yml b/deploy/codefresh/codefresh.yml new file mode 100644 index 0000000..ca170ce --- /dev/null +++ b/deploy/codefresh/codefresh.yml @@ -0,0 +1,35 @@ +version: "1.0" +stages: + - "clone" + - "build" + - "deploy" +steps: + clone: + stage: "clone" + title: "Cloning SCKANNER" + type: "git-clone" + repo: "metacell/sckan-explorer" + revision: "${{CF_BRANCH}}" + build: + stage: "build" + title: "Building SCKANNER" + type: "build" + image_name: "sckanner" + tag: "${{CF_BUILD_ID}}" + dockerfile: Dockerfile + working_directory: ./sckan-explorer + buildkit: true + registry: "${{CODEFRESH_REGISTRY}}" + deploy: + stage: "deploy" + title: "Deploying SCKANNER" + image: codefresh/kubectl + working_directory: ./sckan-explorer/deploy/k8s + commands: + - export CLUSTER_NAME="${{CLUSTER_NAME}}" + - export NAMESPACE="${{NAMESPACE}}" + - export CF_BUILD_ID + - export REGISTRY="${{REGISTRY}}/" + - export DOMAIN="${{DOMAIN}}" + - chmod +x ./deploy.sh + - ./deploy.sh diff --git a/deploy/k8s/codefresh.yaml b/deploy/k8s/codefresh.yaml new file mode 100644 index 0000000..791306c --- /dev/null +++ b/deploy/k8s/codefresh.yaml @@ -0,0 +1,34 @@ +version: "1.0" +stages: + - "clone" + - "build" + - "deploy" +steps: + clone: + stage: "clone" + title: "Cloning SCKANNER" + type: "git-clone" + repo: "metacell/sckan-explorer" + revision: "${{CF_BRANCH}}" + build: + stage: "build" + title: "Building SCKANNER" + type: "build" + image_name: "sckanner" + tag: "${{CF_SHORT_REVISION}}" + dockerfile: Dockerfile + working_directory: ./sckan-explorer + buildkit: true + registry: "${{CODEFRESH_REGISTRY}}" + deploy: + stage: "deploy" + title: "Deploying SCKANNER" + image: codefresh/cf-deploy-kubernetes + tag: latest + working_directory: ./sckan-explorer/deploy/k8s + commands: + - /cf-deploy-kubernetes sckanner.yaml + - /cf-deploy-kubernetes ingress.yaml + environment: + - KUBECONTEXT=${{CLUSTER_NAME}} + - KUBERNETES_NAMESPACE=${{NAMESPACE}} \ No newline at end of file diff --git a/deploy/k8s/deploy.sh b/deploy/k8s/deploy.sh new file mode 100755 index 0000000..49d2dd6 --- /dev/null +++ b/deploy/k8s/deploy.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# set to the correct cluster context and namespace +kubectl config use-context $CLUSTER_NAME +kubectl config set-context $CLUSTER_NAME --namespace=$NAMESPACE + +# prep the yamls +cp sckanner_tpl.yaml sckanner.yaml +cp ingress_tpl.yaml ingress.yaml + +# sckanner service and deployment +sed -ie 's/{{TAG}}/'$CF_BUILD_ID'/i' sckanner.yaml +sed -ie 's|{{REGISTRY}}|'$REGISTRY'|i' sckanner.yaml +kubectl apply -f sds_viewer.yaml + +# ingress +sed -ie 's|{{DOMAIN}}|'$DOMAIN'|i' ingress.yaml +kubectl apply -f ingress.yaml + +# cleanup +rm -rf sckanner.yaml* ingress.yaml* diff --git a/deploy/k8s/deploy_minikube.sh b/deploy/k8s/deploy_minikube.sh new file mode 100755 index 0000000..32b711f --- /dev/null +++ b/deploy/k8s/deploy_minikube.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +export CLUSTER_NAME=minikube +export NAMESPACE=sckanner +export CF_BUILD_ID=latest +export REGISTRY= +export DOMAIN=sckanner.local + +source ./deploy.sh diff --git a/deploy/k8s/ingress.yaml b/deploy/k8s/ingress.yaml new file mode 100644 index 0000000..58498cd --- /dev/null +++ b/deploy/k8s/ingress.yaml @@ -0,0 +1,39 @@ +apiVersion: cert-manager.io/v1 +kind: Issuer +metadata: + name: 'letsencrypt-sckanner' +spec: + acme: + server: https://acme-v02.api.letsencrypt.org/directory + email: filippo@metacell.us + privateKeySecretRef: + name: letsencrypt-sckanner + solvers: + - http01: + ingress: + class: nginx +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + annotations: + cert-manager.io/issuer: letsencrypt-sckanner + kubernetes.io/ingress.class: nginx + kubernetes.io/tls-acme: 'true' + name: sckanner-nginx-ingress +spec: + rules: + - host: "{{DOMAIN}}" + http: + paths: + - backend: + service: + name: sckanner + port: + number: 80 + path: / + pathType: ImplementationSpecific + tls: + - hosts: + - "{{DOMAIN}}" + secretName: sckanner-tls diff --git a/deploy/k8s/sckanner.yaml b/deploy/k8s/sckanner.yaml new file mode 100644 index 0000000..4b36ab8 --- /dev/null +++ b/deploy/k8s/sckanner.yaml @@ -0,0 +1,57 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: sckanner +spec: + selector: + matchLabels: + app: sckanner + replicas: 1 + template: + metadata: + labels: + app: sckanner + spec: + containers: + - name: sckanner + image: "gcr.io/metacellllc/sckanner:{{CF_SHORT_REVISION}}" + imagePullPolicy: "IfNotPresent" + ports: + - containerPort: 80 + livenessProbe: + failureThreshold: 3 + httpGet: + path: /index.html + port: 80 + scheme: HTTP + initialDelaySeconds: 45 + periodSeconds: 30 + timeoutSeconds: 2 + readinessProbe: + failureThreshold: 3 + httpGet: + path: /index.html + port: 80 + scheme: HTTP + initialDelaySeconds: 15 + periodSeconds: 30 + timeoutSeconds: 2 + resources: + limits: + cpu: 1500m + memory: 768Mi + requests: + cpu: 500m + memory: 768Mi +--- +apiVersion: v1 +kind: Service +metadata: + name: sckanner +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: 80 + selector: + app: sckanner diff --git a/nginx/default.bak b/nginx/default.bak new file mode 100644 index 0000000..30beb00 --- /dev/null +++ b/nginx/default.bak @@ -0,0 +1,32 @@ +upstream sckanner { + server sckanner:8000; +} + +server { + listen 80; + + location / { + root /usr/share/nginx/html/; + # index index.html index.htm; + try_files $uri /index.html; + } + + location /sckanner/ { + root /usr/share/nginx/html/; + # index index.html index.htm; + try_files $uri /index.html; + } + + location ~* ^/(admin|api|logged-out|login|sckanner|complete|disconnect|__debug__)/.*$ { + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto https; + proxy_redirect off; + proxy_pass http://sckanner; + } + + location /static/ { + autoindex on; + alias /usr/share/nginx/html/static/; + } +} \ No newline at end of file diff --git a/nginx/default.conf b/nginx/default.conf new file mode 100644 index 0000000..30beb00 --- /dev/null +++ b/nginx/default.conf @@ -0,0 +1,32 @@ +upstream sckanner { + server sckanner:8000; +} + +server { + listen 80; + + location / { + root /usr/share/nginx/html/; + # index index.html index.htm; + try_files $uri /index.html; + } + + location /sckanner/ { + root /usr/share/nginx/html/; + # index index.html index.htm; + try_files $uri /index.html; + } + + location ~* ^/(admin|api|logged-out|login|sckanner|complete|disconnect|__debug__)/.*$ { + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto https; + proxy_redirect off; + proxy_pass http://sckanner; + } + + location /static/ { + autoindex on; + alias /usr/share/nginx/html/static/; + } +} \ No newline at end of file