feat: add account avatars and a deployable image
Accounts get a profile page with an uploaded picture, shown in the sidebar, the room bar, and every human message. Pictures live in the SQLite database and are served through an authenticated route. Hardening from the security audit: preview hosts expire after 24 hours and carry no-referrer; removing a member or archiving a room ends their event feed, presence socket, and terminal within seconds; previews and the terminal pin the SSH host key; invites are claimed atomically; missing accounts spend the same argon2 time as wrong passwords; registration is closed by default; WebSockets check the origin; and the master key is created with mode 0600. The Dockerfile builds one image with the static client and the server. The Helm chart runs a single replica with a SQLite volume, a wildcard preview ingress, and the proxy settings the event feed and uploads need. It refuses more than one replica because state is in process.
This commit is contained in:
1 parent
7e7a1d2bb6
commit
3b82719d56
38 files changed
+1307
-106
No files matched your search
@@ -0,0 +1,11 @@
|
||||
apiVersion: v2
|
||||
name: rhema-together
|
||||
description: A shared room where people and a Rhema agent work on the same code.
|
||||
type: application
|
||||
version: 0.1.0
|
||||
appVersion: "0.1.0"
|
||||
home: https://git.vhaudiquet.fr/vhaudiquet/rhema-together
|
||||
sources:
|
||||
- https://git.vhaudiquet.fr/vhaudiquet/rhema-together
|
||||
maintainers:
|
||||
- name: Valentin Haudiquet
|
||||
@@ -0,0 +1,112 @@
|
||||
# Rhema Together Helm chart
|
||||
|
||||
This chart runs one rhema-together pod with a persistent volume for the
|
||||
SQLite database and the master key. The pod serves the API, the built
|
||||
client, the terminal WebSocket, the event stream, and the preview proxy.
|
||||
|
||||
## Build the image
|
||||
|
||||
```sh
|
||||
docker build -t registry.example.com/rhema-together:0.1.0 .
|
||||
docker push registry.example.com/rhema-together:0.1.0
|
||||
```
|
||||
|
||||
The Dockerfile clones the Rhema framework at `v0.5.1` because this
|
||||
repository consumes its crates by path. Override the pin with
|
||||
`--build-arg RHEMA_REF=<tag>` if you move the framework.
|
||||
|
||||
## Values
|
||||
|
||||
Copy `values.yaml` and change at least these fields:
|
||||
|
||||
```yaml
|
||||
image:
|
||||
repository: registry.example.com/rhema-together
|
||||
tag: "0.1.0"
|
||||
|
||||
app:
|
||||
publicUrl: "https://together.example.com"
|
||||
previewOrigin: "https://preview.together.example.com"
|
||||
allowRegistration: false
|
||||
|
||||
ingress:
|
||||
enabled: true
|
||||
className: nginx
|
||||
annotations:
|
||||
nginx.ingress.kubernetes.io/proxy-body-size: "4m"
|
||||
nginx.ingress.kubernetes.io/proxy-buffering: "off"
|
||||
nginx.ingress.kubernetes.io/proxy-read-timeout: "3600"
|
||||
nginx.ingress.kubernetes.io/proxy-send-timeout: "3600"
|
||||
hosts:
|
||||
- host: together.example.com
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
- host: "*.preview.together.example.com"
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
tls:
|
||||
- secretName: rhema-together-tls
|
||||
hosts:
|
||||
- together.example.com
|
||||
- "*.preview.together.example.com"
|
||||
```
|
||||
|
||||
`publicUrl` and `previewOrigin` must match the hosts and scheme in the
|
||||
ingress. Cookies use `Secure` only when `publicUrl` starts with
|
||||
`https://`; if the browser reaches the app on a different origin, login
|
||||
fails or invite links point elsewhere.
|
||||
|
||||
The preview host is a wildcard because each preview gets a signed
|
||||
subdomain. Point `*.preview.example.com` at the ingress and issue a
|
||||
certificate for that wildcard. With cert-manager, that requires a
|
||||
DNS-01 solver for the zone; an HTTP-01 solver cannot issue wildcards.
|
||||
|
||||
The nginx annotations are not cosmetic. The event feed is server-sent
|
||||
events, so proxy buffering must be off. Avatar uploads are up to 2 MB,
|
||||
so the body size must exceed nginx's 1 MB default. The terminal and
|
||||
preview tunnels use WebSockets and long-lived connections, hence the
|
||||
timeouts.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
helm upgrade --install together deploy/helm/rhema-together \
|
||||
--namespace together --create-namespace \
|
||||
-f my-values.yaml
|
||||
```
|
||||
|
||||
The first-run setup token is in the pod log:
|
||||
|
||||
```sh
|
||||
kubectl logs deploy/together-rhema-together -n together | grep setup
|
||||
```
|
||||
|
||||
Open the app, finish setup, add a provider and an SSH sandbox under
|
||||
Settings, then create a room.
|
||||
|
||||
## Operational notes
|
||||
|
||||
- Run one replica. The database is SQLite and preview tunnels and turn
|
||||
state live in the process. The chart refuses a higher `replicaCount`.
|
||||
- The chart uses `Recreate`, so an upgrade stops the old pod before the
|
||||
new one starts. A rolling update would put two writers on one SQLite
|
||||
file.
|
||||
- The data volume holds `together.db`, its WAL files, and `secret.key`.
|
||||
Losing `secret.key` makes the stored provider and SSH keys unreadable.
|
||||
Back up the volume, or snapshot the PVC, as one unit.
|
||||
- Registration is closed by default. Set `app.allowRegistration: true`
|
||||
only when any visitor should be able to make an account. Setup and
|
||||
invite links work with it closed.
|
||||
- A real account can add an SSH target, and the server then connects
|
||||
where that account says. Keep registration closed unless you trust
|
||||
everyone who can reach the signup page.
|
||||
- Preview hosts are signed capabilities that expire after 24 hours.
|
||||
Reloading the room mints a fresh address; a copied address works for
|
||||
that port until it expires.
|
||||
- The container runs as UID 10001 with a read-only root filesystem.
|
||||
`/data` and `/tmp` are writable. An existing PVC must be writable by
|
||||
GID 10001; the chart sets `fsGroup` for that.
|
||||
- Set `app.previewOrigin: ""` to disable previews. The ingress wildcard
|
||||
can then be removed.
|
||||
@@ -0,0 +1,22 @@
|
||||
Rhema Together is installed.
|
||||
|
||||
{{- if .Values.ingress.enabled }}
|
||||
Open {{ .Values.app.publicUrl }}.
|
||||
{{- else }}
|
||||
Port-forward the service:
|
||||
kubectl port-forward svc/{{ include "rhema-together.fullname" . }} 7800:{{ .Values.service.port }} -n {{ .Release.Namespace }}
|
||||
Then open http://localhost:7800. Set app.publicUrl to that same origin before inviting anyone.
|
||||
{{- end }}
|
||||
|
||||
The first-run setup token is printed by the server:
|
||||
kubectl logs deploy/{{ include "rhema-together.fullname" . }} -n {{ .Release.Namespace }} | grep setup
|
||||
|
||||
{{- if .Values.app.previewOrigin }}
|
||||
Previews use {{ .Values.app.previewOrigin }}. Every preview host under that origin must resolve to this ingress, and the TLS certificate must cover the wildcard host.
|
||||
{{- else }}
|
||||
Previews are disabled.
|
||||
{{- end }}
|
||||
|
||||
{{- if not .Values.persistence.enabled }}
|
||||
Persistence is disabled. Accounts, rooms, and keys disappear when the pod is replaced.
|
||||
{{- end }}
|
||||
@@ -0,0 +1,36 @@
|
||||
{{- define "rhema-together.name" -}}
|
||||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "rhema-together.fullname" -}}
|
||||
{{- if .Values.fullnameOverride }}
|
||||
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
|
||||
{{- else }}
|
||||
{{- $name := default .Chart.Name .Values.nameOverride }}
|
||||
{{- if contains $name .Release.Name }}
|
||||
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
|
||||
{{- else }}
|
||||
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "rhema-together.chart" -}}
|
||||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "rhema-together.labels" -}}
|
||||
helm.sh/chart: {{ include "rhema-together.chart" . }}
|
||||
{{ include "rhema-together.selectorLabels" . }}
|
||||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "rhema-together.selectorLabels" -}}
|
||||
app.kubernetes.io/name: {{ include "rhema-together.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "rhema-together.image" -}}
|
||||
{{- printf "%s:%s" .Values.image.repository (default .Chart.AppVersion .Values.image.tag) }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,111 @@
|
||||
{{- if ne (int .Values.replicaCount) 1 }}
|
||||
{{- fail "replicaCount must be 1: state lives in one SQLite file and in-process tunnels" }}
|
||||
{{- end }}
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ include "rhema-together.fullname" . }}
|
||||
labels:
|
||||
{{- include "rhema-together.labels" . | nindent 4 }}
|
||||
spec:
|
||||
replicas: {{ .Values.replicaCount }}
|
||||
strategy:
|
||||
type: Recreate
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "rhema-together.selectorLabels" . | nindent 6 }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
{{- include "rhema-together.selectorLabels" . | nindent 8 }}
|
||||
{{- with .Values.podLabels }}
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.podAnnotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- with .Values.image.pullSecrets }}
|
||||
imagePullSecrets:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
securityContext:
|
||||
{{- toYaml .Values.podSecurityContext | nindent 8 }}
|
||||
containers:
|
||||
- name: rhema-together
|
||||
image: {{ include "rhema-together.image" . | quote }}
|
||||
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
||||
securityContext:
|
||||
{{- toYaml .Values.securityContext | nindent 12 }}
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: 7800
|
||||
protocol: TCP
|
||||
env:
|
||||
- name: TOGETHER_LISTEN
|
||||
value: "0.0.0.0:7800"
|
||||
- name: TOGETHER_PUBLIC_URL
|
||||
value: {{ required "set app.publicUrl" .Values.app.publicUrl | quote }}
|
||||
- name: TOGETHER_PREVIEW_ORIGIN
|
||||
value: {{ .Values.app.previewOrigin | quote }}
|
||||
- name: TOGETHER_DATABASE
|
||||
value: /data/together.db
|
||||
- name: TOGETHER_SECRET_KEY_FILE
|
||||
value: /data/secret.key
|
||||
- name: TOGETHER_WEB_DIR
|
||||
value: /app/web
|
||||
- name: TOGETHER_ALLOW_REGISTRATION
|
||||
value: {{ .Values.app.allowRegistration | quote }}
|
||||
- name: TOGETHER_MAX_TURN_STEPS
|
||||
value: {{ .Values.app.maxTurnSteps | quote }}
|
||||
- name: RUST_LOG
|
||||
value: {{ .Values.app.logLevel | quote }}
|
||||
{{- with .Values.app.extraEnv }}
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
volumeMounts:
|
||||
- name: data
|
||||
mountPath: /data
|
||||
- name: tmp
|
||||
mountPath: /tmp
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /api/bootstrap
|
||||
port: http
|
||||
initialDelaySeconds: 3
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 3
|
||||
failureThreshold: 3
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /api/bootstrap
|
||||
port: http
|
||||
initialDelaySeconds: 15
|
||||
periodSeconds: 20
|
||||
timeoutSeconds: 3
|
||||
failureThreshold: 3
|
||||
resources:
|
||||
{{- toYaml .Values.resources | nindent 12 }}
|
||||
volumes:
|
||||
- name: data
|
||||
{{- if .Values.persistence.enabled }}
|
||||
persistentVolumeClaim:
|
||||
claimName: {{ .Values.persistence.existingClaim | default (printf "%s-data" (include "rhema-together.fullname" .)) }}
|
||||
{{- else }}
|
||||
emptyDir: {}
|
||||
{{- end }}
|
||||
- name: tmp
|
||||
emptyDir: {}
|
||||
{{- with .Values.nodeSelector }}
|
||||
nodeSelector:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.affinity }}
|
||||
affinity:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.tolerations }}
|
||||
tolerations:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,35 @@
|
||||
{{- if .Values.ingress.enabled }}
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: {{ include "rhema-together.fullname" . }}
|
||||
labels:
|
||||
{{- include "rhema-together.labels" . | nindent 4 }}
|
||||
{{- with .Values.ingress.annotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- with .Values.ingress.className }}
|
||||
ingressClassName: {{ . }}
|
||||
{{- end }}
|
||||
{{- with .Values.ingress.tls }}
|
||||
tls:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
rules:
|
||||
{{- range .Values.ingress.hosts }}
|
||||
- host: {{ .host | quote }}
|
||||
http:
|
||||
paths:
|
||||
{{- range .paths }}
|
||||
- path: {{ .path }}
|
||||
pathType: {{ .pathType }}
|
||||
backend:
|
||||
service:
|
||||
name: {{ include "rhema-together.fullname" $ }}
|
||||
port:
|
||||
name: http
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,17 @@
|
||||
{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }}
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: {{ include "rhema-together.fullname" . }}-data
|
||||
labels:
|
||||
{{- include "rhema-together.labels" . | nindent 4 }}
|
||||
spec:
|
||||
accessModes:
|
||||
- {{ .Values.persistence.accessMode | quote }}
|
||||
resources:
|
||||
requests:
|
||||
storage: {{ .Values.persistence.size | quote }}
|
||||
{{- with .Values.persistence.storageClass }}
|
||||
storageClassName: {{ . | quote }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,15 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ include "rhema-together.fullname" . }}
|
||||
labels:
|
||||
{{- include "rhema-together.labels" . | nindent 4 }}
|
||||
spec:
|
||||
type: {{ .Values.service.type }}
|
||||
ports:
|
||||
- name: http
|
||||
port: {{ .Values.service.port }}
|
||||
targetPort: http
|
||||
protocol: TCP
|
||||
selector:
|
||||
{{- include "rhema-together.selectorLabels" . | nindent 4 }}
|
||||
@@ -0,0 +1,76 @@
|
||||
replicaCount: 1
|
||||
|
||||
image:
|
||||
repository: git.vhaudiquet.fr/vhaudiquet/rhema-together
|
||||
# Defaults to Chart.AppVersion.
|
||||
tag: ""
|
||||
pullPolicy: IfNotPresent
|
||||
pullSecrets: []
|
||||
|
||||
nameOverride: ""
|
||||
fullnameOverride: ""
|
||||
|
||||
app:
|
||||
# The browser URL. Invite links and cookies use this exact origin.
|
||||
publicUrl: "https://together.example.com"
|
||||
# Previews are served from this origin. Set it to "" to disable them.
|
||||
previewOrigin: "https://preview.together.example.com"
|
||||
# Closed by default: the setup account and invite links are enough.
|
||||
# Open it only when any visitor should be able to make an account.
|
||||
allowRegistration: false
|
||||
maxTurnSteps: 48
|
||||
logLevel: "rhema_together=info,tower_http=warn"
|
||||
extraEnv: []
|
||||
|
||||
service:
|
||||
type: ClusterIP
|
||||
port: 7800
|
||||
|
||||
ingress:
|
||||
enabled: false
|
||||
className: ""
|
||||
annotations: {}
|
||||
hosts:
|
||||
- host: together.example.com
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
- host: "*.preview.together.example.com"
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
tls: []
|
||||
# - secretName: rhema-together-tls
|
||||
# hosts:
|
||||
# - together.example.com
|
||||
# - "*.preview.together.example.com"
|
||||
|
||||
persistence:
|
||||
enabled: true
|
||||
existingClaim: ""
|
||||
storageClass: ""
|
||||
accessMode: ReadWriteOnce
|
||||
size: 5Gi
|
||||
|
||||
podAnnotations: {}
|
||||
podLabels: {}
|
||||
|
||||
podSecurityContext:
|
||||
fsGroup: 10001
|
||||
fsGroupChangePolicy: OnRootMismatch
|
||||
|
||||
securityContext:
|
||||
runAsNonRoot: true
|
||||
runAsUser: 10001
|
||||
runAsGroup: 10001
|
||||
allowPrivilegeEscalation: false
|
||||
readOnlyRootFilesystem: true
|
||||
capabilities:
|
||||
drop:
|
||||
- ALL
|
||||
|
||||
resources: {}
|
||||
|
||||
nodeSelector: {}
|
||||
tolerations: []
|
||||
affinity: {}
|
||||
Reference in new issue
Block a user