latexgrambot: inline LaTeX bot for Telegram in Go

Renders LaTeX expressions into PNG pictures, PDF documents and native
Telegram rich text messages, entirely locally with TeX Live and poppler.

- Chat mode with /image, /pdf, /rich plus per-user preamble and DPI
- Inline mode delivering picture, PDF and rich text results
- Broad default package set preloaded into a TeX format at image build
- MongoDB persistence: settings, users, groups, render statistics
- Private S3-compatible bucket with short-lived presigned URLs
- OpenTelemetry traces over OTLP
- Kubernetes manifests and Argo CD application, Docker Compose, GitHub
  Actions CI, BSD 3-Clause license
This commit is contained in:
corrado.mulas
2026-10-04 03:38:08 +02:00
commit 98a3614d58
29 changed files with 5140 additions and 0 deletions

70
k8s/deployment.yaml Normal file
View File

@@ -0,0 +1,70 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: latexgrambot
namespace: latexgrambot
labels:
app.kubernetes.io/name: latexgrambot
spec:
# Exactly one replica: the bot long-polls Telegram (getUpdates) and
# Telegram allows a single consumer per bot token.
replicas: 1
strategy:
type: Recreate
selector:
matchLabels:
app.kubernetes.io/name: latexgrambot
template:
metadata:
labels:
app.kubernetes.io/name: latexgrambot
spec:
securityContext:
runAsNonRoot: true
runAsUser: 1000
runAsGroup: 1000
seccompProfile:
type: RuntimeDefault
containers:
- name: latexgrambot
# Replace with the image built by CI, e.g. your registry plus the
# commit SHA tag.
image: latexgrambot:latest
imagePullPolicy: IfNotPresent
envFrom:
- configMapRef:
name: latexgrambot
- secretRef:
name: latexgrambot-secrets
- secretRef:
name: latexgrambot-s3
ports:
- name: http
containerPort: 8080
readinessProbe:
httpGet:
path: /readyz
port: http
initialDelaySeconds: 5
periodSeconds: 10
timeoutSeconds: 5
livenessProbe:
httpGet:
path: /healthz
port: http
initialDelaySeconds: 15
periodSeconds: 30
# pdflatex is CPU-bound; the memory limit has to cover a TeX Live
# run (a few hundred MB per concurrent render).
resources:
requests:
cpu: 100m
memory: 128Mi
limits:
cpu: "2"
memory: 1Gi
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL