Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add single room mode #72

Draft
wants to merge 19 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- nic/env/fosdem-2023
pull_request:

env:
Expand Down Expand Up @@ -107,6 +108,54 @@ jobs:
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}

build-bot:
name: Build Bot
runs-on: ubuntu-latest
timeout-minutes: 15
outputs:
docker-tag: ${{ steps.meta.outputs.version }}
steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Login to ghcr.io
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Generate Docker metadata
id: meta
uses: docker/metadata-action@v4
env:
DOCKER_METADATA_PR_HEAD_SHA: true
with:
images: ghcr.io/nordeck/matrix-barcamp-bot
labels: |
org.opencontainers.image.title=Matrix BarCamp Bot
org.opencontainers.image.description=A bot accompanying the BarCamp widget to support clients without support for the required widget API calls
org.opencontainers.image.vendor=Nordeck IT + Consulting GmbH
tags: |
type=sha,prefix=
type=raw,value=latest,enable={{is_default_branch}}

- name: Build and push
uses: docker/build-push-action@v3
id: dockerBuild
with:
push: ${{ secrets.GH_APP_OS_APP_ID != '' }}
context: matrix-barcamp-bot
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
#platforms: linux/amd64,linux/arm64,linux/s390x

e2e:
runs-on: ubuntu-latest
timeout-minutes: 25
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,6 @@ build/
/test-results/
/playwright-report/
/playwright/.cache/

# jetbrains
/.idea/*
23 changes: 23 additions & 0 deletions charts/matrix-barcamp-bot/.helmignore
Original file line number Diff line number Diff line change
@@ -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/
7 changes: 7 additions & 0 deletions charts/matrix-barcamp-bot/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v2
name: matrix-barcamp-bot
description: A bot accompanying the BarCamp widget to support clients without support for the required widget API calls
type: application
version: 0.1.0
appVersion: "0.0.0"
home: https://github.com/nordeck/matrix-barcamp
1 change: 1 addition & 0 deletions charts/matrix-barcamp-bot/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TODO: Invite the user xxx to start
51 changes: 51 additions & 0 deletions charts/matrix-barcamp-bot/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "matrix-barcamp-bot.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "matrix-barcamp-bot.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 }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "matrix-barcamp-bot.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "matrix-barcamp-bot.labels" -}}
helm.sh/chart: {{ include "matrix-barcamp-bot.chart" . }}
{{ include "matrix-barcamp-bot.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "matrix-barcamp-bot.selectorLabels" -}}
app.kubernetes.io/name: {{ include "matrix-barcamp-bot.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
15 changes: 15 additions & 0 deletions charts/matrix-barcamp-bot/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "matrix-barcamp-bot.fullname" . }}
labels:
{{- include "matrix-barcamp-bot.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "matrix-barcamp-bot.selectorLabels" . | nindent 4 }}
98 changes: 98 additions & 0 deletions charts/matrix-barcamp-bot/templates/statefulset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ include "matrix-barcamp-bot.fullname" . }}
labels:
{{- include "matrix-barcamp-bot.labels" . | nindent 4 }}
spec:
replicas: 1
serviceName: {{ include "matrix-barcamp-bot.fullname" . }}
selector:
matchLabels:
{{- include "matrix-barcamp-bot.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "matrix-barcamp-bot.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
#ports:
# - name: http
# containerPort: 80
# protocol: TCP
#livenessProbe:
# httpGet:
# path: /
# port: http
#readinessProbe:
# httpGet:
# path: /
# port: http
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
- name: config
mountPath: /usr/src/app/config.toml
subPath: "config.toml"
- name: bot-data
mountPath: /data
subPath: {{ .Values.persistence.subPath }}
volumes:
- name: "config"
secret:
secretName: {{ .Values.config.secretName }}
{{- if not .Values.persistence.enabled }}
- name: "bot-data"
emptyDir: {}
{{- else }}
{{- if .Values.persistence.existingClaim }}
- name: "bot-data"
persistentVolumeClaim:
claimName: {{ .Values.persistence.existingClaim }}
{{- end }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }}
volumeClaimTemplates:
- metadata:
name: bot-data
labels:
{{- include "matrix-barcamp-bot.labels" . | nindent 10 }}
spec:
accessModes:
{{- range .Values.persistence.accessModes }}
- {{ . | quote }}
{{- end }}
resources:
requests:
storage: {{ .Values.persistence.size | quote }}
{{- with .Values.persistence.storageClassName }}
storageClassName: {{ . }}
{{- end }}
{{- end }}
12 changes: 12 additions & 0 deletions charts/matrix-barcamp-bot/values.demo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# helm upgrade -n env-demo --install matrix-barcamp-bot ./charts/matrix-barcamp-bot -f ./charts/matrix-barcamp-bot/values.demo.yaml

image:
tag: "efb4729"

persistence:
enabled: true
size: 1Gi
storageClassName: gp2

config:
secretName: "matrix-barcamp-bot-config"
85 changes: 85 additions & 0 deletions charts/matrix-barcamp-bot/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Default values for matrix-barcamp-bot.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

replicaCount: 1

image:
repository: ghcr.io/nordeck/matrix-barcamp-bot
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: ""

imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""

podAnnotations: {}

podSecurityContext: {}
# fsGroup: 2000

securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000

service:
type: ClusterIP
port: 8080

resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi

nodeSelector: {}

tolerations: []

affinity: {}

persistence:
enabled: false
# The subdirectory of the volume to mount to, useful in dev environments
# and one PV for multiple services.
subPath: ""
# Persistent Volume Storage Class
# If defined, storageClassName: <storageClass>
# storageClassName: ""
accessModes:
- ReadWriteOnce
size: 8Gi

config:
# The name of the secret that contains a `config.toml` key
#
# Example:
#
# apiVersion: v1
# kind: Secret
# metadata:
# name: secret-name
# type: Opaque
# stringData:
# 'config.toml': |
# [simplematrixbotlib.config]
# homeserver = "https://example.org"
# username = "example-barcamp-bot"
# password = "test123"
# join_on_invite = true
# store_path = "/data/store/"
# allowlist = []
# blocklist = []
# session_stored_file: "/data/session.txt"
secretName: ""
Binary file added docs/img/barcamp-bot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions matrix-barcamp-bot/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/session.txt
/store/
/venv/
config.toml
12 changes: 12 additions & 0 deletions matrix-barcamp-bot/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM python:3.10-slim

ENV PYTHONUNBUFFERED=1

WORKDIR /usr/src/app

COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt

COPY . .

CMD [ "python", "./main.py" ]
Loading