From 59f62eaf19cfaa5da8931bc8918f911104009895 Mon Sep 17 00:00:00 2001 From: Sam J Combs Date: Tue, 17 Dec 2024 19:17:53 -0500 Subject: [PATCH] chore: wider cors + helm updates (fix ports + load balancer) --- backend/package.json | 2 +- backend/src/server.ts | 10 +--------- frontend/package.json | 2 +- helm/Chart.yaml | 2 +- helm/templates/deployment.yaml | 5 ++++- helm/templates/ingress.yaml | 18 ++++++++++++++++++ helm/templates/pv.yaml | 11 +++++++++++ helm/templates/service.yaml | 2 +- helm/values.yaml | 4 ++-- package.json | 2 +- 10 files changed, 41 insertions(+), 17 deletions(-) create mode 100644 helm/templates/ingress.yaml create mode 100644 helm/templates/pv.yaml diff --git a/backend/package.json b/backend/package.json index d274751..8396425 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "backend", - "version": "1.0.0-beta.4.1", + "version": "1.0.0-beta.4.3", "main": "dist/server.js", "scripts": { "build": "rm -rf dist/ && npx tsc && npm run copy-graphql", diff --git a/backend/src/server.ts b/backend/src/server.ts index 78db70a..5145c8e 100644 --- a/backend/src/server.ts +++ b/backend/src/server.ts @@ -120,15 +120,7 @@ const initializeApp = async () => { app.use(express.urlencoded({limit: '50mb', extended: true})); app.use( cors({ - origin: (origin, callback) => { - const allowedOrigins = [getWebsiteDomain()]; - const regex = - /^(https:\/\/[a-zA-Z0-9-]+\.narrative\.tech|https?:\/\/localhost(:\d+)?|https:\/\/[a-zA-Z0-9-]+\.xspecs\.io)$/; - - if (!origin || allowedOrigins.includes(origin) || regex.test(origin)) - callback(null, true); - else callback(new Error('Not allowed by CORS')); - }, + origin: '*', allowedHeaders: [ 'content-type', ...supertokens.getAllCORSHeaders(), diff --git a/frontend/package.json b/frontend/package.json index 7011480..e43432f 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "frontend", - "version": "1.0.0-beta.4.1", + "version": "1.0.0-beta.4.3", "private": true, "dependencies": { "@apollo/explorer": "^3.7.0", diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 5a37518..4c2c59d 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,4 +2,4 @@ apiVersion: v2 name: instantmock description: A Helm chart for deploying InstantMock version: 0.2.0 -appVersion: "1.0.0-beta.4.1" +appVersion: '1.0.0-beta.4.3' diff --git a/helm/templates/deployment.yaml b/helm/templates/deployment.yaml index c90ac2f..bbe0f37 100644 --- a/helm/templates/deployment.yaml +++ b/helm/templates/deployment.yaml @@ -16,7 +16,10 @@ spec: - name: backend image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" ports: - - containerPort: 3007 + - containerPort: 3033 + env: + - name: NODE_ENV + value: "production" volumeMounts: - mountPath: /app/backend/data name: sqlite-storage diff --git a/helm/templates/ingress.yaml b/helm/templates/ingress.yaml new file mode 100644 index 0000000..6adf942 --- /dev/null +++ b/helm/templates/ingress.yaml @@ -0,0 +1,18 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ .Release.Name }}-ingress + annotations: + nginx.ingress.kubernetes.io/rewrite-target: / +spec: + rules: + - host: example.com + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: {{ .Release.Name }}-backend + port: + number: {{ .Values.service.port }} \ No newline at end of file diff --git a/helm/templates/pv.yaml b/helm/templates/pv.yaml new file mode 100644 index 0000000..a2289fc --- /dev/null +++ b/helm/templates/pv.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: instant-mock-pv +spec: + capacity: + storage: 1Gi + accessModes: + - ReadWriteOnce + hostPath: + path: /mnt/data diff --git a/helm/templates/service.yaml b/helm/templates/service.yaml index 98f2ede..f71fbfa 100644 --- a/helm/templates/service.yaml +++ b/helm/templates/service.yaml @@ -6,6 +6,6 @@ spec: type: {{ .Values.service.type }} ports: - port: {{ .Values.service.port }} - targetPort: 3007 + targetPort: 3033 selector: app: {{ .Release.Name }}-backend \ No newline at end of file diff --git a/helm/values.yaml b/helm/values.yaml index 2b81248..3b3efb7 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -1,10 +1,10 @@ replicaCount: 1 image: repository: xolvio/instant-mock - tag: 1.0.0-beta.4.1 + tag: 1.0.0-beta.4.3 pullPolicy: Always service: - type: ClusterIP + type: LoadBalancer port: 80 resources: {} persistence: diff --git a/package.json b/package.json index 3b05986..7546b6b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "instant-mock", - "version": "1.0.0-beta.4.1", + "version": "1.0.0-beta.4.3", "description": "![instant-mock-screen-cap-final](https://github.com/user-attachments/assets/de0f50d4-5a71-4e5a-b479-37c6cfa0481d)", "main": "index.js", "module": "true",