diff --git a/synapse/app.yaml b/synapse/app.yaml new file mode 100644 index 0000000..6d40a4d --- /dev/null +++ b/synapse/app.yaml @@ -0,0 +1,5 @@ +name: synapse +is: synapse +description: Synapse is the reference Matrix homeserver for self-hosted, federated, end-to-end encrypted messaging. +icon: https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/svg/matrix.svg +latest: "v1" diff --git a/synapse/versions/v1/README.md b/synapse/versions/v1/README.md new file mode 100644 index 0000000..b781f66 --- /dev/null +++ b/synapse/versions/v1/README.md @@ -0,0 +1,38 @@ +# Synapse + +Synapse is the reference Matrix homeserver for self-hosted, federated, end-to-end encrypted messaging. + +## Dependencies + +- **PostgreSQL** - Database for storing messages and account data +- **Redis** - Used for inter-worker communication + +## Configuration + +Key settings configured through your instance's `config.yaml`: + +- **domain** - Where the Synapse web client will be accessible (default: `synapse.{your-cloud-domain}`) +- **serverName** - Your Matrix server identity, used in user IDs like `@user:{serverName}` (default: `{your-cloud-domain}`) +- **enableRegistration** - Whether to allow public account creation (default: `false`) +- **storage** - Persistent volume for Synapse data (default: `2Gi`) +- **mediaStorage** - Persistent volume for uploaded media (default: `2Gi`) +- **SMTP** - Email delivery settings inherited from your Wild Cloud instance + +## Access + +After deployment, the Synapse homeserver will be available at: +- `https://synapse.{your-cloud-domain}` + +Connect using any Matrix client (Element, FluffyChat, etc.) with your server name. + +## First-Time Setup + +1. Add and deploy the app: + ```bash + wild app add synapse + wild app deploy synapse + ``` + +2. Use the registration shared secret (in your `secrets.yaml`) to create your first admin account, or enable public registration temporarily + +3. Connect with a Matrix client and start messaging diff --git a/synapse/versions/v1/configmap.yaml b/synapse/versions/v1/configmap.yaml new file mode 100644 index 0000000..c3f7c6b --- /dev/null +++ b/synapse/versions/v1/configmap.yaml @@ -0,0 +1,67 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: synapse-config +data: + homeserver.yaml: | + server_name: "{{ .serverName }}" + public_baseurl: https://{{ .domain }} + + listeners: + - port: 8008 + tls: false + type: http + x_forwarded: true + bind_addresses: ['::'] + resources: + - names: [client, federation] + compress: false + + database: + name: psycopg2 + args: + user: {{ .db.user }} + password: ${DB_PASSWORD} + database: {{ .db.name }} + host: {{ .db.host }} + port: 5432 + cp_min: 5 + cp_max: 10 + + redis: + enabled: true + host: {{ .redis.host }} + port: 6379 + password: ${REDIS_PASSWORD} + + media_store_path: /data/media_store + uploads_path: /data/uploads + + max_upload_size: 100M + + enable_registration: {{ .enableRegistration }} + enable_registration_without_verification: {{ .enableRegistration }} + registration_shared_secret: "${REGISTRATION_SHARED_SECRET}" + + macaroon_secret_key: "${MACAROON_SECRET_KEY}" + form_secret: "${FORM_SECRET}" + + signing_key_path: /data/keys/signing.key + + trusted_key_servers: + - server_name: "matrix.org" + + email: + smtp_host: "{{ .smtp.host }}" + smtp_port: {{ .smtp.port }} + smtp_user: "{{ .smtp.user }}" + smtp_pass: "${SMTP_PASSWORD}" + require_transport_security: {{ .smtp.requireTls }} + notif_from: "{{ .smtp.from }}" + app_name: Matrix + + report_stats: false + + enable_metrics: true + + suppress_key_server_warning: true diff --git a/synapse/versions/v1/db-init-job.yaml b/synapse/versions/v1/db-init-job.yaml new file mode 100644 index 0000000..9a4330e --- /dev/null +++ b/synapse/versions/v1/db-init-job.yaml @@ -0,0 +1,57 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: synapse-db-init +spec: + template: + spec: + containers: + - name: db-init + image: postgres:17 + command: ["/bin/bash", "-c"] + args: + - | + PGPASSWORD=${POSTGRES_ADMIN_PASSWORD} psql -h ${DB_HOSTNAME} -U postgres </dev/null)" +if [ -z "${POD}" ]; then + echo "ERROR: No running Synapse pod found in namespace ${NAMESPACE}" + exit 1 +fi + +if [ -z "${PASSWORD}" ]; then + PASSWORD="$(openssl rand -base64 24 | tr -d '/+=' | head -c 24)" +fi + +if [ "${ADMIN}" = "true" ] || [ "${ADMIN}" = "1" ]; then + ADMIN_FLAG="-a" +else + ADMIN_FLAG="--no-admin" +fi + +echo "Creating user '@${USERNAME}:${SERVER_NAME}' (admin: ${ADMIN})..." + +kubectl exec -n "${NAMESPACE}" "${POD}" -- \ + register_new_matrix_user \ + -k "${REGISTRATION_SHARED_SECRET}" \ + -u "${USERNAME}" \ + -p "${PASSWORD}" \ + ${ADMIN_FLAG} \ + http://localhost:8008 + +echo "" +echo "=== User created ===" +echo "Username: @${USERNAME}:${SERVER_NAME}" +echo "Password: ${PASSWORD}" +echo "" +echo "Save this password — it will not be shown again." diff --git a/synapse/versions/v1/service.yaml b/synapse/versions/v1/service.yaml new file mode 100644 index 0000000..152e96a --- /dev/null +++ b/synapse/versions/v1/service.yaml @@ -0,0 +1,14 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: synapse +spec: + type: ClusterIP + ports: + - name: http + port: 8008 + targetPort: 8008 + protocol: TCP + selector: + component: synapse