Zhichao commited on
Commit
f2de1e7
1 Parent(s): 46f65e5

GitHub action for build and deploy to aws dev (#67)

Browse files

<img width="834" alt="image"
src="https://github.com/landing-ai/vision-agent-ui/assets/7520479/0240ebdd-43b7-4c91-a1a0-8100abe97666">

<img width="1023" alt="image"
src="https://github.com/landing-ai/vision-agent-ui/assets/7520479/7a7d62ef-1906-4e0b-b3c8-1ae9be5967a0">

<img width="267" alt="image"
src="https://github.com/landing-ai/vision-agent-ui/assets/7520479/a1a83eb7-a36e-4e68-aae7-093b09a83b60">

.dockerignore ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ node_modules
2
+ npm-debug.log
3
+ Dockerfile*
4
+ docker-compose*
5
+ .dockerignore
6
+ .git
7
+ .gitignore
8
+ README.md
9
+ LICENSE
10
+ .vscode
11
+ .github
.github/workflows/cicd.yaml ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: build and publish to aws development
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ env:
9
+ repo_name: "vision-agent"
10
+ aws_account_id: "970073041993"
11
+ aws_region: "us-east-2"
12
+ cluster_name: "landinglens"
13
+ namespace: "datamanagement"
14
+
15
+ jobs:
16
+ build:
17
+ runs-on: ubuntu-latest
18
+ environment: aws-development
19
+
20
+ permissions:
21
+ id-token: write
22
+ contents: read
23
+
24
+ outputs:
25
+ image_tag: ${{ steps.sha_short.outputs.image_tag }}
26
+
27
+ steps:
28
+ - uses: actions/checkout@v4
29
+
30
+ - name: Configure AWS Credentials
31
+ uses: aws-actions/configure-aws-credentials@v4
32
+ with:
33
+ role-to-assume: arn:aws:iam::${{ env.aws_account_id }}:role/github-actions-role
34
+ aws-region: ${{ env.aws_region }}
35
+
36
+ - name: Login to Amazon ECR
37
+ id: login-ecr
38
+ uses: aws-actions/amazon-ecr-login@v2
39
+ with:
40
+ registries: ${{ env.aws_account_id }}
41
+ mask-password: "true" # see: https://github.com/aws-actions/amazon-ecr-login#docker-credentials
42
+
43
+ - name: Set short sha
44
+ id: sha_short
45
+ run: |
46
+ echo "image_tag=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
47
+
48
+ - uses: docker/setup-buildx-action@v3
49
+ - name: Build and push
50
+ uses: docker/build-push-action@v5
51
+ with:
52
+ context: .
53
+ file: ./Dockerfile
54
+ push: true
55
+ tags: ${{ steps.login-ecr.outputs.registry }}/${{ env.repo_name }}:${{ steps.sha_short.outputs.image_tag }}
56
+ cache-from: type=gha
57
+ cache-to: type=gha,mode=max
58
+ provenance: false
59
+ secrets: |
60
+ AUTH_SECRET=${{ vars.AUTH_SECRET }}
61
+ OPENAI_API_KEY=${{ vars.OPENAI_API_KEY }}
62
+
63
+ detect_migration_changes:
64
+ runs-on: ubuntu-latest
65
+ outputs:
66
+ migrations: ${{ steps.filter.outputs.migrations }}
67
+ steps:
68
+ - uses: actions/checkout@v4
69
+ - uses: dorny/paths-filter@v3
70
+ id: filter
71
+ with:
72
+ filters: |
73
+ migrations:
74
+ - 'prisma/migrations/**'
75
+
76
+ db_migration:
77
+ needs: changes
78
+ if: ${{ needs.changes.outputs.migrations == 'true' }}
79
+ runs-on: ubuntu-latest
80
+ environment: aws-development
81
+
82
+ permissions:
83
+ id-token: write
84
+ contents: read
85
+
86
+ steps:
87
+ - uses: actions/checkout@v4
88
+ - name: Set up Node.js
89
+ uses: actions/setup-node@v4
90
+ with:
91
+ node-version: "20"
92
+
93
+ - name: Install pnpm
94
+ run: npm install -g [email protected]
95
+
96
+ - name: Install dependencies
97
+ run: pnpm install
98
+
99
+ - name: prisma migrate deploy
100
+ env:
101
+ POSTGRES_PRISMA_URL: ${{ vars.DB_MIGRATION_URL }}
102
+ POSTGRES_URL_NON_POOLING: ${{ vars.DB_MIGRATION_URL }}
103
+ run: |
104
+ mkdir -p ~/.ssh
105
+ echo "${{ secrets.BASTION_SSH_KEY }}" > ~/.ssh/id_ed25519
106
+ chmod 600 ~/.ssh/id_ed25519
107
+ ssh-keyscan -H 3.142.222.176 >> ~/.ssh/known_hosts
108
+ ssh -o StrictHostKeyChecking=no -fN -v -L localhost:5432:platform.db.app.dev.landing.ai:5432 [email protected]
109
+ pnpm prisma migrate deploy
110
+
111
+ deploy_to_aws_development:
112
+ needs: build
113
+
114
+ runs-on: ubuntu-latest
115
+ environment: aws-development
116
+
117
+ permissions:
118
+ id-token: write
119
+ contents: read
120
+
121
+ steps:
122
+ - uses: actions/checkout@v4
123
+
124
+ - name: Configure AWS Credentials
125
+ uses: aws-actions/configure-aws-credentials@v4
126
+ with:
127
+ role-to-assume: arn:aws:iam::${{ env.aws_account_id }}:role/github-actions-role
128
+ aws-region: ${{ env.aws_region }}
129
+
130
+ - name: kubeconfig
131
+ run: |
132
+ aws sts get-caller-identity
133
+ aws eks update-kubeconfig --name ${{ env.cluster_name }} --region ${{ env.aws_region }}
134
+
135
+ - name: install helm
136
+ run: |
137
+ curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
138
+
139
+ - name: helm upgrade --install
140
+ env:
141
+ IMAGE_TAG: ${{ needs.build.outputs.image_tag }}
142
+ run: |
143
+ helm upgrade --install -n ${{ env.namespace }} ${{ env.repo_name }} -f chart/${{ vars.VALUES_FILE }} ./chart \
144
+ --set image.tag=$IMAGE_TAG \
145
+ --set env.AWS_BUCKET_NAME=${{ vars.AWS_BUCKET_NAME }} \
146
+ --set env.AWS_REGION=${{ vars.AWS_REGION }} \
147
+ --set env.NEXTAUTH_URL=${{ vars.NEXTAUTH_URL }} \
148
+ --set env.AUTH_GITHUB_ID=${{ vars.AUTH_GITHUB_ID }} \
149
+ --set env.AUTH_GITHUB_SECRET=${{ vars.AUTH_GITHUB_SECRET }} \
150
+ --set env.AUTH_SECRET=${{ vars.AUTH_SECRET }} \
151
+ --set env.AUTH_TRUST_HOST=${{ vars.AUTH_TRUST_HOST }} \
152
+ --set env.AWS_ACCESS_KEY_ID=${{ vars.AWS_ACCESS_KEY_ID }} \
153
+ --set env.AWS_SECRET_ACCESS_KEY=${{ vars.AWS_SECRET_ACCESS_KEY }} \
154
+ --set env.GOOGLE_CLIENT_ID=${{ vars.GOOGLE_CLIENT_ID }} \
155
+ --set env.GOOGLE_SECRET=${{ vars.GOOGLE_SECRET }} \
156
+ --set env.LOKI_AUTH_USER_PASSWORD=${{ vars.LOKI_AUTH_USER_PASSWORD }} \
157
+ --set env.OPENAI_API_KEY=${{ vars.OPENAI_API_KEY }} \
158
+ --set env.POSTGRES_PRISMA_URL=${{ vars.POSTGRES_PRISMA_URL }}
Dockerfile CHANGED
@@ -5,7 +5,7 @@ RUN corepack enable
5
 
6
  FROM base AS deps
7
  WORKDIR /app
8
- COPY package.json pnpm-lock.yaml ./
9
  RUN pnpm i --frozen-lockfile
10
 
11
  # Rebuild the source code only when needed
@@ -15,12 +15,11 @@ COPY --from=deps --link /app/node_modules ./node_modules
15
  COPY --link . .
16
 
17
  RUN --mount=type=secret,id=AUTH_SECRET \
18
- --mount=type=secret,id=OPENAI_API_KEY \
19
- AUTH_SECRET="$(cat /run/secrets/AUTH_SECRET)" \
20
- OPENAI_API_KEY="$(cat /run/secrets/OPENAI_API_KEY)" \
21
- NEXT_SHARP_PATH="/app/node_modules/sharp" \
22
- USE_STANDALONE_BUILD=True \
23
- pnpm run build
24
 
25
  RUN mkdir -p /app/.next/cache/images
26
 
@@ -39,11 +38,9 @@ COPY --from=builder --link --chown=1000:1000 /app/.next/standalone ./
39
  COPY --from=builder --link --chown=1000:1000 /app/.next/static ./.next/static
40
  COPY --from=builder --link --chown=1000:1000 /app/.next/cache/images ./.next/cache/images
41
 
42
- USER nextjs
43
 
44
- EXPOSE 7860
45
-
46
- ENV PORT 7860
47
  ENV HOSTNAME 0.0.0.0
48
 
49
  CMD ["node", "server.js"]
 
5
 
6
  FROM base AS deps
7
  WORKDIR /app
8
+ COPY package.json pnpm-lock.yaml prisma/* ./
9
  RUN pnpm i --frozen-lockfile
10
 
11
  # Rebuild the source code only when needed
 
15
  COPY --link . .
16
 
17
  RUN --mount=type=secret,id=AUTH_SECRET \
18
+ --mount=type=secret,id=OPENAI_API_KEY \
19
+ AUTH_SECRET="$(cat /run/secrets/AUTH_SECRET)" \
20
+ OPENAI_API_KEY="$(cat /run/secrets/OPENAI_API_KEY)" \
21
+ USE_STANDALONE_BUILD=True \
22
+ pnpm run build
 
23
 
24
  RUN mkdir -p /app/.next/cache/images
25
 
 
38
  COPY --from=builder --link --chown=1000:1000 /app/.next/static ./.next/static
39
  COPY --from=builder --link --chown=1000:1000 /app/.next/cache/images ./.next/cache/images
40
 
41
+ EXPOSE 3000
42
 
43
+ ENV PORT 3000
 
 
44
  ENV HOSTNAME 0.0.0.0
45
 
46
  CMD ["node", "server.js"]
chart/.helmignore ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Patterns to ignore when building packages.
2
+ # This supports shell glob matching, relative path matching, and
3
+ # negation (prefixed with !). Only one pattern per line.
4
+ .DS_Store
5
+ # Common VCS dirs
6
+ .git/
7
+ .gitignore
8
+ .bzr/
9
+ .bzrignore
10
+ .hg/
11
+ .hgignore
12
+ .svn/
13
+ # Common backup files
14
+ *.swp
15
+ *.bak
16
+ *.tmp
17
+ *.orig
18
+ *~
19
+ # Various IDEs
20
+ .project
21
+ .idea/
22
+ *.tmproj
23
+ .vscode/
chart/Chart.yaml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ apiVersion: v2
2
+ name: vision-agent
3
+ description: A Helm chart for LandingAI Vision Agent
4
+
5
+ # A chart can be either an 'application' or a 'library' chart.
6
+ #
7
+ # Application charts are a collection of templates that can be packaged into versioned archives
8
+ # to be deployed.
9
+ #
10
+ # Library charts provide useful utilities or functions for the chart developer. They're included as
11
+ # a dependency of application charts to inject those utilities and functions into the rendering
12
+ # pipeline. Library charts do not define any templates and therefore cannot be deployed.
13
+ type: application
14
+
15
+ # This is the chart version. This version number should be incremented each time you make changes
16
+ # to the chart and its templates, including the app version.
17
+ # Versions are expected to follow Semantic Versioning (https://semver.org/)
18
+ version: 0.1.0
19
+
20
+ # This is the version number of the application being deployed. This version number should be
21
+ # incremented each time you make changes to the application. Versions are not expected to
22
+ # follow Semantic Versioning. They should reflect the version the application is using.
23
+ # It is recommended to use it with quotes.
24
+ appVersion: "1.16.0"
chart/dev.values.yaml ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ ingressRoute:
2
+ matchRule: "Host(`va.dev.landing.ai`)"
chart/prod.values.yaml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ ingressRoute:
2
+ matchRule: "Host(`va.landing.ai`)"
3
+
4
+ autoscaling:
5
+ enabled: true
6
+ minReplicas: 3
7
+ maxReplicas: 9
chart/templates/NOTES.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ 1. Get the application URL by running these commands:
2
+ {{- if .Values.ingressRoute.enabled }}
3
+ {{ .Values.ingressRoute.matchRule }}
4
+ {{- end }}
chart/templates/_helpers.tpl ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {{/*
2
+ Expand the name of the chart.
3
+ */}}
4
+ {{- define "chart.name" -}}
5
+ {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6
+ {{- end }}
7
+
8
+ {{/*
9
+ Create a default fully qualified app name.
10
+ We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11
+ If release name contains chart name it will be used as a full name.
12
+ */}}
13
+ {{- define "chart.fullname" -}}
14
+ {{- if .Values.fullnameOverride }}
15
+ {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16
+ {{- else }}
17
+ {{- $name := default .Chart.Name .Values.nameOverride }}
18
+ {{- if contains $name .Release.Name }}
19
+ {{- .Release.Name | trunc 63 | trimSuffix "-" }}
20
+ {{- else }}
21
+ {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22
+ {{- end }}
23
+ {{- end }}
24
+ {{- end }}
25
+
26
+ {{/*
27
+ Create chart name and version as used by the chart label.
28
+ */}}
29
+ {{- define "chart.chart" -}}
30
+ {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31
+ {{- end }}
32
+
33
+ {{/*
34
+ Common labels
35
+ */}}
36
+ {{- define "chart.labels" -}}
37
+ helm.sh/chart: {{ include "chart.chart" . }}
38
+ {{ include "chart.selectorLabels" . }}
39
+ {{- if .Chart.AppVersion }}
40
+ app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41
+ {{- end }}
42
+ app.kubernetes.io/managed-by: {{ .Release.Service }}
43
+ {{- end }}
44
+
45
+ {{/*
46
+ Selector labels
47
+ */}}
48
+ {{- define "chart.selectorLabels" -}}
49
+ app.kubernetes.io/name: {{ include "chart.name" . }}
50
+ app.kubernetes.io/instance: {{ .Release.Name }}
51
+ {{- end }}
52
+
53
+ {{/*
54
+ Create the name of the service account to use
55
+ */}}
56
+ {{- define "chart.serviceAccountName" -}}
57
+ {{- if .Values.serviceAccount.create }}
58
+ {{- default (include "chart.fullname" .) .Values.serviceAccount.name }}
59
+ {{- else }}
60
+ {{- default "default" .Values.serviceAccount.name }}
61
+ {{- end }}
62
+ {{- end }}
chart/templates/configmap.yaml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ apiVersion: v1
2
+ kind: ConfigMap
3
+ metadata:
4
+ name: env-config-{{ include "chart.fullname" . }}
5
+ labels:
6
+ {{- include "chart.labels" . | nindent 4 }}
7
+ data:
8
+ {{- toYaml .Values.env | nindent 2 }}
chart/templates/deployment.yaml ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ apiVersion: apps/v1
2
+ kind: Deployment
3
+ metadata:
4
+ name: {{ include "chart.fullname" . }}
5
+ labels:
6
+ {{- include "chart.labels" . | nindent 4 }}
7
+ spec:
8
+ {{- if not .Values.autoscaling.enabled }}
9
+ replicas: {{ .Values.replicaCount }}
10
+ {{- end }}
11
+ selector:
12
+ matchLabels:
13
+ {{- include "chart.selectorLabels" . | nindent 6 }}
14
+ template:
15
+ metadata:
16
+ {{- with .Values.podAnnotations }}
17
+ annotations:
18
+ {{- toYaml . | nindent 8 }}
19
+ {{- end }}
20
+ labels:
21
+ {{- include "chart.labels" . | nindent 8 }}
22
+ {{- with .Values.podLabels }}
23
+ {{- toYaml . | nindent 8 }}
24
+ {{- end }}
25
+ spec:
26
+ {{- with .Values.imagePullSecrets }}
27
+ imagePullSecrets:
28
+ {{- toYaml . | nindent 8 }}
29
+ {{- end }}
30
+ serviceAccountName: {{ include "chart.serviceAccountName" . }}
31
+ securityContext:
32
+ {{- toYaml .Values.podSecurityContext | nindent 8 }}
33
+ containers:
34
+ - name: {{ .Chart.Name }}
35
+ securityContext:
36
+ {{- toYaml .Values.securityContext | nindent 12 }}
37
+ image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
38
+ imagePullPolicy: {{ .Values.image.pullPolicy }}
39
+ ports:
40
+ - name: http
41
+ containerPort: {{ .Values.service.port }}
42
+ protocol: TCP
43
+ envFrom:
44
+ - configMapRef:
45
+ name: env-config-{{ include "chart.fullname" . }}
46
+ # - secretRef:
47
+ # name: secrets-{{ include "chart.fullname" . }}
48
+ livenessProbe:
49
+ {{- toYaml .Values.livenessProbe | nindent 12 }}
50
+ readinessProbe:
51
+ {{- toYaml .Values.readinessProbe | nindent 12 }}
52
+ resources:
53
+ {{- toYaml .Values.resources | nindent 12 }}
54
+ {{- with .Values.volumeMounts }}
55
+ volumeMounts:
56
+ {{- toYaml . | nindent 12 }}
57
+ {{- end }}
58
+ {{- with .Values.volumes }}
59
+ volumes:
60
+ {{- toYaml . | nindent 8 }}
61
+ {{- end }}
62
+ {{- with .Values.nodeSelector }}
63
+ nodeSelector:
64
+ {{- toYaml . | nindent 8 }}
65
+ {{- end }}
66
+ {{- with .Values.affinity }}
67
+ affinity:
68
+ {{- toYaml . | nindent 8 }}
69
+ {{- end }}
70
+ {{- with .Values.tolerations }}
71
+ tolerations:
72
+ {{- toYaml . | nindent 8 }}
73
+ {{- end }}
chart/templates/hpa.yaml ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {{- if .Values.autoscaling.enabled }}
2
+ apiVersion: autoscaling/v2
3
+ kind: HorizontalPodAutoscaler
4
+ metadata:
5
+ name: {{ include "chart.fullname" . }}
6
+ labels:
7
+ {{- include "chart.labels" . | nindent 4 }}
8
+ spec:
9
+ scaleTargetRef:
10
+ apiVersion: apps/v1
11
+ kind: Deployment
12
+ name: {{ include "chart.fullname" . }}
13
+ minReplicas: {{ .Values.autoscaling.minReplicas }}
14
+ maxReplicas: {{ .Values.autoscaling.maxReplicas }}
15
+ metrics:
16
+ {{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
17
+ - type: Resource
18
+ resource:
19
+ name: cpu
20
+ target:
21
+ type: Utilization
22
+ averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
23
+ {{- end }}
24
+ {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
25
+ - type: Resource
26
+ resource:
27
+ name: memory
28
+ target:
29
+ type: Utilization
30
+ averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
31
+ {{- end }}
32
+ {{- end }}
chart/templates/ingressroute.yaml ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {{- if .Values.ingressRoute.enabled -}}
2
+ apiVersion: traefik.containo.us/v1alpha1
3
+ kind: IngressRoute
4
+ metadata:
5
+ name: {{ include "chart.fullname" . }}
6
+ annotations:
7
+ {{- with .Values.ingressRoute.annotations }}
8
+ {{- toYaml . | nindent 4 }}
9
+ {{- end }}
10
+ labels:
11
+ {{- include "chart.labels" . | nindent 4 }}
12
+ {{- with .Values.ingressRoute.labels }}
13
+ {{- toYaml . | nindent 4 }}
14
+ {{- end }}
15
+ spec:
16
+ entryPoints:
17
+ {{- range .Values.ingressRoute.entryPoints }}
18
+ - {{ . }}
19
+ {{- end }}
20
+ routes:
21
+ - kind: Rule
22
+ match: {{ .Values.ingressRoute.matchRule }}
23
+ services:
24
+ - name: {{ include "chart.fullname" . }}
25
+ port: {{ .Values.service.port }}
26
+ {{- with .Values.ingressRoute.middlewares }}
27
+ middlewares:
28
+ {{- toYaml . | nindent 6 }}
29
+ {{- end -}}
30
+
31
+ {{- with .Values.ingressRoute.tls }}
32
+ tls:
33
+ {{- toYaml . | nindent 4 }}
34
+ {{- end }}
35
+ {{- end -}}
chart/templates/service.yaml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ apiVersion: v1
2
+ kind: Service
3
+ metadata:
4
+ name: {{ include "chart.fullname" . }}
5
+ labels:
6
+ {{- include "chart.labels" . | nindent 4 }}
7
+ spec:
8
+ type: {{ .Values.service.type }}
9
+ ports:
10
+ - port: {{ .Values.service.port }}
11
+ targetPort: http
12
+ protocol: TCP
13
+ name: http
14
+ selector:
15
+ {{- include "chart.selectorLabels" . | nindent 4 }}
chart/templates/serviceaccount.yaml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {{- if .Values.serviceAccount.create -}}
2
+ apiVersion: v1
3
+ kind: ServiceAccount
4
+ metadata:
5
+ name: {{ include "chart.serviceAccountName" . }}
6
+ labels:
7
+ {{- include "chart.labels" . | nindent 4 }}
8
+ {{- with .Values.serviceAccount.annotations }}
9
+ annotations:
10
+ {{- toYaml . | nindent 4 }}
11
+ {{- end }}
12
+ automountServiceAccountToken: {{ .Values.serviceAccount.automount }}
13
+ {{- end }}
chart/templates/tests/test-connection.yaml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ apiVersion: v1
2
+ kind: Pod
3
+ metadata:
4
+ name: "{{ include "chart.fullname" . }}-test-connection"
5
+ labels:
6
+ {{- include "chart.labels" . | nindent 4 }}
7
+ annotations:
8
+ "helm.sh/hook": test
9
+ spec:
10
+ containers:
11
+ - name: wget
12
+ image: busybox
13
+ command: ['wget']
14
+ args: ['{{ include "chart.fullname" . }}:{{ .Values.service.port }}']
15
+ restartPolicy: Never
chart/values.yaml ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Default values for chart.
2
+ # This is a YAML-formatted file.
3
+ # Declare variables to be passed into your templates.
4
+
5
+ replicaCount: 1
6
+
7
+ image:
8
+ repository: 970073041993.dkr.ecr.us-east-2.amazonaws.com/vision-agent
9
+ pullPolicy: IfNotPresent
10
+ # Overrides the image tag whose default is the chart appVersion.
11
+ tag: "latest"
12
+
13
+ imagePullSecrets: []
14
+ nameOverride: "vision-agent"
15
+ fullnameOverride: ""
16
+
17
+ serviceAccount:
18
+ # Specifies whether a service account should be created
19
+ create: false
20
+ # Automatically mount a ServiceAccount's API credentials?
21
+ automount: true
22
+ # Annotations to add to the service account
23
+ annotations: {}
24
+ # The name of the service account to use.
25
+ # If not set and create is true, a name is generated using the fullname template
26
+ name: "clef-user"
27
+
28
+ podAnnotations: {}
29
+ podLabels: {}
30
+
31
+ podSecurityContext:
32
+ {}
33
+ # fsGroup: 2000
34
+
35
+ securityContext:
36
+ {}
37
+ # capabilities:
38
+ # drop:
39
+ # - ALL
40
+ # readOnlyRootFilesystem: true
41
+ # runAsNonRoot: true
42
+ # runAsUser: 1000
43
+
44
+ service:
45
+ type: ClusterIP
46
+ port: 3000
47
+
48
+ ingressRoute:
49
+ enabled: true
50
+ entryPoints:
51
+ - websecure
52
+ matchRule: ""
53
+
54
+ resources:
55
+ # We usually recommend not to specify default resources and to leave this as a conscious
56
+ # choice for the user. This also increases chances charts run on environments with little
57
+ # resources, such as Minikube. If you do want to specify resources, uncomment the following
58
+ # lines, adjust them as necessary, and remove the curly braces after 'resources:'.
59
+ # limits:
60
+ # cpu: 100m
61
+ # memory: 128Mi
62
+ # requests:
63
+ # cpu: 100m
64
+ # memory: 128Mi
65
+
66
+ livenessProbe:
67
+ httpGet:
68
+ path: /
69
+ port: http
70
+ readinessProbe:
71
+ httpGet:
72
+ path: /
73
+ port: http
74
+
75
+ autoscaling:
76
+ enabled: false
77
+ minReplicas: 1
78
+ maxReplicas: 9
79
+ targetCPUUtilizationPercentage: 60
80
+ # targetMemoryUtilizationPercentage: 80
81
+
82
+ env:
83
+ AUTH_GITHUB_ID: ""
84
+ AUTH_GITHUB_SECRET: ""
85
+ AUTH_SECRET: ""
86
+ AUTH_TRUST_HOST: ""
87
+ AWS_ACCESS_KEY_ID: ""
88
+ AWS_BUCKET_NAME: ""
89
+ AWS_REGION: ""
90
+ AWS_SECRET_ACCESS_KEY: ""
91
+ COREPACK_ENABLE_STRICT: "0"
92
+ ENABLE_EXPERIMENTAL_COREPACK: "1"
93
+ GOOGLE_CLIENT_ID: ""
94
+ GOOGLE_SECRET: ""
95
+ LOKI_AUTH_USER_ID: "173854"
96
+ LOKI_AUTH_USER_PASSWORD: ""
97
+ OPENAI_API_KEY: ""
98
+ POSTGRES_PRISMA_URL: ""
99
+ NEXTAUTH_URL: ""
100
+
101
+ # Additional volumes on the output Deployment definition.
102
+ volumes: []
103
+ # - name: foo
104
+ # secret:
105
+ # secretName: mysecret
106
+ # optional: false
107
+
108
+ # Additional volumeMounts on the output Deployment definition.
109
+ volumeMounts: []
110
+ # - name: foo
111
+ # mountPath: "/etc/foo"
112
+ # readOnly: true
113
+
114
+ nodeSelector: {}
115
+
116
+ tolerations: []
117
+
118
+ affinity: {}
prisma/migrations/20240524012008_init/migration.sql CHANGED
@@ -17,6 +17,7 @@ CREATE TABLE "chat" (
17
  "id" TEXT NOT NULL,
18
  "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
19
  "updated_at" TIMESTAMP(3) NOT NULL,
 
20
  "userId" TEXT,
21
  "mediaUrl" TEXT NOT NULL,
22
 
@@ -31,6 +32,7 @@ CREATE TABLE "message" (
31
  "userId" TEXT,
32
  "chatId" TEXT NOT NULL,
33
  "content" TEXT NOT NULL,
 
34
  "role" "MessageRole" NOT NULL,
35
 
36
  CONSTRAINT "message_pkey" PRIMARY KEY ("id")
 
17
  "id" TEXT NOT NULL,
18
  "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
19
  "updated_at" TIMESTAMP(3) NOT NULL,
20
+ "title" TEXT NOT NULL DEFAULT '(no title)',
21
  "userId" TEXT,
22
  "mediaUrl" TEXT NOT NULL,
23
 
 
32
  "userId" TEXT,
33
  "chatId" TEXT NOT NULL,
34
  "content" TEXT NOT NULL,
35
+ "result" JSONB,
36
  "role" "MessageRole" NOT NULL,
37
 
38
  CONSTRAINT "message_pkey" PRIMARY KEY ("id")
prisma/migrations/20240604162153_combine_user_and_assistant_message/migration.sql ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Warnings:
3
+
4
+ - You are about to drop the column `content` on the `message` table. All the data in the column will be lost.
5
+ - You are about to drop the column `role` on the `message` table. All the data in the column will be lost.
6
+ - Added the required column `mediaUrl` to the `message` table without a default value. This is not possible if the table is not empty.
7
+ - Added the required column `prompt` to the `message` table without a default value. This is not possible if the table is not empty.
8
+
9
+ */
10
+ -- AlterTable
11
+ ALTER TABLE "message" DROP COLUMN "content",
12
+ DROP COLUMN "role",
13
+ ADD COLUMN "mediaUrl" TEXT NOT NULL,
14
+ ADD COLUMN "prompt" TEXT NOT NULL,
15
+ ADD COLUMN "response" TEXT;
16
+
17
+ -- DropEnum
18
+ DROP TYPE "MessageRole";