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

#SDSV-24 - Add codefresh deployment pipeline on Metacell kubernetes cluster #214

Merged
merged 15 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 23 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
# node-sass 4.14.1 requires node version <= 14 for Alpine Linux
# See: https://github.com/sass/node-sass/releases/tag/v4.14.1
FROM node:16-alpine as build-deps
WORKDIR /usr/src/app
RUN pwd && ls
COPY yarn.lock ./
ARG NODE_PARENT=node:16-alpine

FROM ${NODE_PARENT} as frontend

ENV BUILDDIR=/app

RUN apk add git
RUN npm i -g @craco/craco

WORKDIR ${BUILDDIR}
COPY package.json ${BUILDDIR}
COPY yarn.lock ${BUILDDIR}
COPY nginx/default.conf ${BUILDDIR}

RUN yarn install
COPY . ./
COPY . ${BUILDDIR}
RUN yarn build

COPY public/ ./public/
COPY src/ ./src/
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/build /usr/share/nginx/html/

EXPOSE 3000
CMD yarn run start
EXPOSE 80
34 changes: 34 additions & 0 deletions deploy/k8s/codefresh.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
version: "1.0"
stages:
- "clone"
- "build"
- "deploy"
steps:
clone:
stage: "clone"
title: "Cloning SDS Viewer"
type: "git-clone"
repo: "metacell/sds-viewer"
revision: "${{CF_BRANCH}}"
build:
stage: "build"
title: "Building SDS Viewer"
type: "build"
image_name: "sds-viewer"
tag: "${{CF_SHORT_REVISION}}"
dockerfile: Dockerfile
working_directory: ./sds-viewer
buildkit: true
registry: "${{CODEFRESH_REGISTRY}}"
deploy:
stage: "deploy"
title: "Deploying SDS Viewer"
image: codefresh/cf-deploy-kubernetes
tag: latest
working_directory: ./sds-viewer/deploy/k8s
commands:
- /cf-deploy-kubernetes sds_viewer.yaml
- /cf-deploy-kubernetes ingress.yaml
environment:
- KUBECONTEXT=${{CLUSTER_NAME}}
- KUBERNETES_NAMESPACE=${{NAMESPACE}}
19 changes: 8 additions & 11 deletions deploy/k8s/ingress_tpl.yaml → deploy/k8s/ingress.yaml
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,42 +1,39 @@
apiVersion: cert-manager.io/v1alpha2
apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
name: 'letsencrypt-sds_viewer'
name: 'letsencrypt-sds-viewer'
spec:
acme:
server: https://acme-v02.api.letsencrypt.org/directory
email: [email protected]
privateKeySecretRef:
name: letsencrypt-sds_viewer
name: letsencrypt-sds-viewer
solvers:
- http01:
ingress:
ingressName: sds_viewer
class: nginx
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
cert-manager.io/issuer: letsencrypt-sds_viewer
cert-manager.io/issuer: letsencrypt-sds-viewer
kubernetes.io/ingress.class: nginx
kubernetes.io/tls-acme: 'true'
nginx.ingress.kubernetes.io/ssl-redirect: 'true'
nginx.ingress.kubernetes.io/proxy-body-size: 512m
nginx.ingress.kubernetes.io/from-to-www-redirect: 'true'
name: sds_viewer
name: sds-viewer-nginx-ingress
spec:
rules:
- host: "{{DOMAIN}}"
http:
paths:
- backend:
service:
name: sds_viewer
name: sds-viewer
port:
number: 80
path: /
pathType: ImplementationSpecific
tls:
- hosts:
- "{{DOMAIN}}"
secretName: sds_viewer-tls
secretName: sds-viewer-tls
57 changes: 57 additions & 0 deletions deploy/k8s/sds_viewer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: sds-viewer
spec:
selector:
matchLabels:
app: sds-viewer
replicas: 1
template:
metadata:
labels:
app: sds-viewer
spec:
containers:
- name: sds-viewer
image: "gcr.io/metacellllc/sds-viewer:{{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: sds-viewer
spec:
type: ClusterIP
ports:
- port: 80
targetPort: 80
selector:
app: sds-viewer
39 changes: 0 additions & 39 deletions deploy/k8s/sds_viewer_tpl.yaml

This file was deleted.

32 changes: 32 additions & 0 deletions nginx/default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
upstream sds-viewer {
server sds-viewer:8000;
}

server {
listen 80;

location / {
root /usr/share/nginx/html/;
# index index.html index.htm;
try_files $uri /index.html;
}

location /sds-viewer/ {
root /usr/share/nginx/html/;
# index index.html index.htm;
try_files $uri /index.html;
}

location ~* ^/(admin|api|logged-out|login|sds-viewer|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://sds-viewer;
}

location /static/ {
autoindex on;
alias /usr/share/nginx/html/static/;
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.1.0",
"license": "MIT",
"private": true,
"homepage": "http://metacell.github.io/sds-viewer",
"homepage": "./",
"dependencies": {
"@craco/craco": "^6.1.2",
"@frogcat/ttl2jsonld": "^0.0.7",
Expand Down
Loading