Etherpad: Installer configuration

Change-Id: I808e3c1835e2f0bf5fe2e0da138710c979a38e38
diff --git a/charts/etherpad/.helmignore b/charts/etherpad/.helmignore
new file mode 100644
index 0000000..0e8a0eb
--- /dev/null
+++ b/charts/etherpad/.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/charts/etherpad/Chart.yaml b/charts/etherpad/Chart.yaml
new file mode 100644
index 0000000..3f4d17b
--- /dev/null
+++ b/charts/etherpad/Chart.yaml
@@ -0,0 +1,6 @@
+apiVersion: v2
+name: etherpad
+description: A Helm chart for etherpad
+type: application
+version: 0.0.1
+appVersion: "0.0.1"
diff --git a/charts/etherpad/templates/install.yaml b/charts/etherpad/templates/install.yaml
new file mode 100644
index 0000000..a7d924b
--- /dev/null
+++ b/charts/etherpad/templates/install.yaml
@@ -0,0 +1,73 @@
+apiVersion: v1
+kind: Service
+metadata:
+  name: etherpad
+  namespace: {{ .Release.Namespace }}
+spec:
+  type: ClusterIP
+  selector:
+    app: etherpad
+  ports:
+  - name: {{ .Values.portName }}
+    port: 80
+    targetPort: {{ .Values.portName }}
+    protocol: TCP
+---
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  name: etherpad
+  namespace: {{ .Release.Namespace }}
+spec:
+  selector:
+    matchLabels:
+      app: etherpad
+  replicas: 1
+  template:
+    metadata:
+      labels:
+        app: etherpad
+    spec:
+      volumes:
+      - name: data
+        persistentVolumeClaim:
+          claimName: {{ .Values.persistentVolumeClaimName }}
+      containers:
+      - name: etherpad
+        image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
+        imagePullPolicy: {{ .Values.image.pullPolicy }}
+        ports:
+        - name: {{ .Values.portName }}
+          containerPort: 8080
+          protocol: TCP
+        env:
+        - name: "PORT"
+          value: "8080"
+        - name: "NODE_ENV"
+          value: "production"
+        - name: "ADMIN_PASSWORD"
+          value: "admin"
+        - name: "USER_PASSWORD"
+          value: "user"
+        - name: "DEFAULT_PAD_TEXT"
+          value: "dodo"
+        - name: "TRUST_PROXY"
+          value: "true"
+        - name: "DB_TYPE"
+          value: "{{ .Values.db.type }}"
+        - name: "DB_HOST"
+          value: "{{ .Values.db.host }}"
+        - name: "DB_PORT"
+          value: "{{ .Values.db.port }}"
+        - name: "DB_NAME"
+          value: "{{ .Values.db.name }}"
+        - name: "DB_USER"
+          value: "{{ .Values.db.user }}"
+        - name: "DB_PASS"
+          value: "{{ .Values.db.pass }}"
+        - name: "DB_CHARSET"
+          value: "{{ .Values.db.charset }}"
+        volumeMounts:
+        - name: data
+          mountPath: /var/lib/etherpad
+          readOnly: false
diff --git a/charts/etherpad/values.yaml b/charts/etherpad/values.yaml
new file mode 100644
index 0000000..ab5d5eb
--- /dev/null
+++ b/charts/etherpad/values.yaml
@@ -0,0 +1,14 @@
+image:
+  repository: etherpad/etherpad
+  tag: latest
+  pullPolicy: Always
+portName: http
+persistentVolumeClaimName: "data"
+db:
+  type: ""
+  host: ""
+  port: 80
+  name: ""
+  user: ""
+  pass: ""
+  charset: ""
diff --git a/core/installer/app_repository.go b/core/installer/app_repository.go
index e4f462e..e0f97fc 100644
--- a/core/installer/app_repository.go
+++ b/core/installer/app_repository.go
@@ -25,6 +25,7 @@
 	"values-tmpl/url-shortener.cue",
 	"values-tmpl/matrix.cue",
 	"values-tmpl/vaultwarden.cue",
+	"values-tmpl/etherpad.cue",
 	// "values-tmpl/open-project.cue",
 	"values-tmpl/gerrit.cue",
 	"values-tmpl/jenkins.cue",
diff --git a/core/installer/values-tmpl/etherpad.cue b/core/installer/values-tmpl/etherpad.cue
new file mode 100644
index 0000000..980c5eb
--- /dev/null
+++ b/core/installer/values-tmpl/etherpad.cue
@@ -0,0 +1,82 @@
+input: {
+	network: #Network @name(Network)
+	subdomain: string @name(Subdomain)
+	auth: #Auth @name(Authentication)
+}
+
+_domain: "\(input.subdomain).\(input.network.domain)"
+
+name: "etherpad"
+namespace: "app-etherpad"
+readme: "Etherpad is a highly customizable open source online editor providing collaborative editing in really real-time."
+description: "Etherpad is a highly customizable open source online editor providing collaborative editing in really real-time."
+icon: """
+<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 0 48 48"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" d="M38.5 5.5h-29c-2.2 0-4 1.8-4 4v29c0 2.2 1.8 4 4 4h29c2.2 0 4-1.8 4-4v-29c0-2.2-1.8-4-4-4"/><circle cx="24" cy="24" r="13.9" fill="none" stroke="currentColor" stroke-miterlimit="7"/><path fill="none" stroke="currentColor" d="M14.5 5.5v37m19-37v37"/></svg>"""
+
+_httpPortName: "http"
+
+out: {
+	ingress: {
+		etherpad: {
+			auth: input.auth
+			network: input.network
+			subdomain: input.subdomain
+			service: {
+				name: "etherpad"
+				port: name: _httpPortName
+			}
+		}
+	}
+
+	images: {
+		etherpad: {
+			repository: "etherpad"
+			name: "etherpad"
+			tag: "2.2.5"
+			pullPolicy: "IfNotPresent"
+		}
+	}
+
+	charts: {
+		etherpad: {
+			kind: "GitRepository"
+			address: "https://code.v1.dodo.cloud/helm-charts"
+			branch: "main"
+			path: "charts/etherpad"
+		}
+	}
+
+	volumes: data: size: "1Gi"
+
+	postgresql: db: {
+		name: "db"
+		size: "10Gi"
+	}
+
+	helm: {
+		etherpad: {
+			chart: charts.etherpad
+			info: "Installing etherpad server"
+			values: {
+				image: {
+					repository: images.etherpad.fullName
+					tag: images.etherpad.tag
+					pullPolicy: images.etherpad.pullPolicy
+				}
+				portName: _httpPortName
+				persistentVolumeClaimName: volumes.data.name
+				db: {
+					type: "postgres"
+					host: "postgres-db.\(release.namespace).svc.cluster.local"
+					port: 5432
+					name: "postgres"
+					user: "postgres"
+					pass: "postgres"
+					charset: "utf8mb4"
+				}
+			}
+		}
+	}
+}
+
+url: "https://\(_domain)"