slidge: Add service for legacy protocol bridging

This commit is contained in:
Alex Palaistras 2022-12-13 00:11:56 +00:00
parent c2c8d746cd
commit 560cfc82b6
5 changed files with 90 additions and 0 deletions

View File

@ -13,6 +13,7 @@ PROSODY_HOST=prosody.localhost
PROSODY_HOST_EXTERNAL=prosody-external.localhost
PROSODY_BIBOUMI_PASSWORD=password
PROSODY_SPECTRUM_PASSWORD=password
PROSODY_SLIDGE_PASSWORD=password
# Configuration for Coturn.
COTURN_AUTH_SECRET=password
@ -70,3 +71,6 @@ GOTOSOCIAL_HOST=social.localhost
GOTOSOCIAL_ACCOUNT_DOMAIN=localhost
GOTOSOCIAL_DEFAULT_USERNAME=default
GOTOSOCIAL_SMTP_FROM=noreply@social.localhost
# Configuration for Slidge.
SLIDGE_SECRET_KEY=password

View File

@ -0,0 +1,45 @@
FROM docker.io/debian:bullseye-slim AS builder
ARG VERSION=1d2ca68a96d79a8354359926bd7091e9553ebbb0
ARG PLUGINS="skype discord"
RUN apt-get update -y && apt-get install -y --no-install-recommends \
ca-certificates git curl python3 python3-pip python3-venv
RUN git clone https://git.sr.ht/~nicoco/slidge /slidge && \
cd /slidge && git reset --hard ${VERSION}
ENV PATH=/venv/bin:/root/.local/bin:$PATH
RUN python3 -m venv /venv && python3 -m pip install wheel
RUN curl -fL https://install.python-poetry.org | python3 -
RUN cd /slidge && poetry export --extras="$PLUGINS" > requirements.txt && \
python3 -m pip install --requirement requirements.txt
RUN cp -R /slidge/slidge /venv/lib/python3.9/site-packages/slidge
FROM docker.io/golang:1.19-bullseye AS builder-whatsapp
ENV GOBIN=/usr/bin
RUN go install github.com/go-python/gopy@latest && \
go install golang.org/x/tools/cmd/goimports@latest
RUN apt-get update -y && apt-get install -y --no-install-recommends \
ca-certificates python3 python3-dev python3-pip
RUN python3 -m pip install pybindgen
COPY --from=builder /slidge /
RUN cd /slidge/plugins/whatsapp && gopy build -vm=python3 -output=generated -no-make=true .
FROM docker.io/debian:bullseye-slim
RUN apt-get update -y && apt-get install -y --no-install-recommends \
ca-certificates python3 libpython3.9 python3-gdbm
ENV PYTHONUNBUFFERED=1
ENV PATH=/venv/bin:$PATH
COPY --from=builder /venv /venv
COPY --from=builder-whatsapp /slidge/plugins/whatsapp/generated /venv/lib/python3.9/site-packages/slidge/plugins/whatsapp/generated
ENTRYPOINT ["python", "-m", "slidge"]

View File

@ -0,0 +1,10 @@
# Options for Slidge.
SLIDGE_SERVER=prosody
SLIDGE_SECRET=${PROSODY_SLIDGE_PASSWORD}
SLIDGE_SECRET_KEY=${SLIDGE_SECRET_KEY}
SLIDGE_HOME_DIR=/var/lib/slidge
SLIDGE_USER_JID_VALIDATOR=.*@${PROSODY_HOST}
SLIDGE_UPLOAD_SERVICE=${PROSODY_HOST_EXTERNAL}
# Options for Prosody component configuration.
PROSODY_COMPONENT_PASSWORD=${PROSODY_SLIDGE_PASSWORD}

8
service/slidge/spec.bu Normal file
View File

@ -0,0 +1,8 @@
variant: fcos
version: 1.3.0
storage:
trees:
- path: /etc/coreos-home-server/slidge
local: service/slidge/
- path: /etc/systemd/system
local: service/slidge/systemd/

View File

@ -0,0 +1,23 @@
[Unit]
Description=Slidge Gateway for XMPP (%i)
Wants=container-build@%p.service container-volume@%p-%i.service prosody.service prosody-component-register@%p-%i.service
After=container-build@%p.service container-volume@%p-%i.service prosody.service prosody-component-register@%p-%i.service
[Service]
Type=notify
NotifyAccess=all
SyslogIdentifier=%N
Restart=on-failure
Environment=PODMAN_SYSTEMD_UNIT=%n
EnvironmentFile=%E/coreos-home-server/prosody/prosody.env
ExecStart=/bin/podman run --replace --name %p-%i --net internal --sdnotify=conmon \
--env-file %E/coreos-home-server/%p/%p.env \
--volume %p-%i:/var/lib/slidge:z \
localhost/%p:latest \
--jid=%i.${PROSODY_HOST} \
--legacy-module=slidge.plugins.%i
ExecStop=/bin/podman stop --ignore --time 10 %p-%i
ExecStopPost=/bin/podman rm --ignore --force %p-%i
[Install]
WantedBy=multi-user.target