diff --git a/.github/helm/affine-cloud/.helmignore b/.github/helm/affine-cloud/.helmignore new file mode 100644 index 0000000000..0e8a0eb36f --- /dev/null +++ b/.github/helm/affine-cloud/.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/ diff --git a/.github/helm/affine-cloud/Chart.lock b/.github/helm/affine-cloud/Chart.lock new file mode 100644 index 0000000000..e43c19b00a --- /dev/null +++ b/.github/helm/affine-cloud/Chart.lock @@ -0,0 +1,6 @@ +dependencies: +- name: postgresql + repository: https://charts.bitnami.com/bitnami + version: 12.5.8 +digest: sha256:c91c0dc1370e879538dc9d6e435e731a726ef99d6a3b081372318483792b48a7 +generated: "2023-06-27T18:34:12.683806+08:00" diff --git a/.github/helm/affine-cloud/Chart.yaml b/.github/helm/affine-cloud/Chart.yaml new file mode 100644 index 0000000000..fa4e1695e6 --- /dev/null +++ b/.github/helm/affine-cloud/Chart.yaml @@ -0,0 +1,12 @@ +apiVersion: v2 +name: affine-cloud +description: A Helm chart for AFFiNE Cloud + +type: application +version: 0.6.0 +appVersion: '0.6.0' + +dependencies: + - name: postgresql + version: 12.5.8 + repository: https://charts.bitnami.com/bitnami diff --git a/.github/helm/affine-cloud/charts/postgresql-12.5.8.tgz b/.github/helm/affine-cloud/charts/postgresql-12.5.8.tgz new file mode 100644 index 0000000000..1c2df40510 Binary files /dev/null and b/.github/helm/affine-cloud/charts/postgresql-12.5.8.tgz differ diff --git a/.github/helm/affine-cloud/templates/deployment.yaml b/.github/helm/affine-cloud/templates/deployment.yaml new file mode 100644 index 0000000000..37acfc45fa --- /dev/null +++ b/.github/helm/affine-cloud/templates/deployment.yaml @@ -0,0 +1,49 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: affine-cloud +spec: + replicas: 1 + selector: + matchLabels: + app: affine-cloud + strategy: + type: RollingUpdate + rollingUpdate: + maxUnavailable: 2 + template: + metadata: + labels: + app: affine-cloud + spec: + restartPolicy: Always + containers: + - name: affine-cloud + image: "ghcr.io/toeverything/cloud-self-hosted:{{ .Values.affineCloud.tag | default .Chart.AppVersion }}" + env: + - name: PG_USER + value: "{{ .Values.postgresql.auth.username }}" + - name: PG_PASS + value: "{{ .Values.postgresql.auth.password }}" + - name: PG_DATABASE + value: "{{ .Values.postgresql.auth.database }}" + - name: PG_HOST + value: "{{ .Release.Name }}-postgresql" + - name: DATABASE_URL + value: "{{ default "postgresql://$(PG_USER):$(PG_PASS)@$(PG_HOST)/$(PG_DATABASE)" .Values.affineCloud.databaseUrl }}" + envFrom: + - secretRef: + name: affine-cloud-secret + ports: + - containerPort: 3000 + livenessProbe: + httpGet: + path: /api/healthz + port: 3000 + failureThreshold: 1 + initialDelaySeconds: 10 + periodSeconds: 10 + resources: + limits: + cpu: "{{ .Values.affineCloud.resources.cpu }}" + memory: "{{ .Values.affineCloud.resources.memory }}" diff --git a/.github/helm/affine-cloud/templates/secret.yaml b/.github/helm/affine-cloud/templates/secret.yaml new file mode 100644 index 0000000000..170a5b90d1 --- /dev/null +++ b/.github/helm/affine-cloud/templates/secret.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: Secret +metadata: + name: affine-cloud-secret +type: Opaque +data: + # only for demo, please modify it at prod env + SIGN_KEY: TUFtdFdzQTJhdGJuem01TA== +# MAIL_ACCOUNT: XXXX +# MAIL_PASSWORD: XXXX diff --git a/.github/helm/affine-cloud/templates/services.yaml b/.github/helm/affine-cloud/templates/services.yaml new file mode 100644 index 0000000000..ec0b2f8c72 --- /dev/null +++ b/.github/helm/affine-cloud/templates/services.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + name: affine-cloud +spec: + type: ClusterIP + selector: + app: affine-cloud + ports: + - name: affine-cloud + protocol: TCP + port: 3000 + targetPort: 3000 diff --git a/.github/helm/affine-cloud/values.yaml b/.github/helm/affine-cloud/values.yaml new file mode 100644 index 0000000000..e1bad387ea --- /dev/null +++ b/.github/helm/affine-cloud/values.yaml @@ -0,0 +1,21 @@ +affineCloud: + tag: 'nightly-latest' + resources: + cpu: '250m' + memory: 0.5Gi +postgresql: + auth: + # only for demo, please modify it at prod env + username: affine + password: XJYMLnuBJS27a2du + database: affine + primary: + initdb: + scripts: + 01-init.sql: | + CREATE DATABASE affine_binary; + GRANT ALL PRIVILEGES ON DATABASE affine_binary TO affine; + resources: + limits: + cpu: '500m' + memory: 0.5Gi