FROM cloudron/base:5.0.0@sha256:04fd70dbd8ad6149c19de39e35718e024417c3e01dc9c6637eaf4a41ec4e596c

RUN mkdir -p /app/pkg

WORKDIR /app/code

# https://github.com/element-hq/synapse/blob/master/docs/setup/installation.md?plain=1#L202
RUN python3 -m venv /app/code/env

# renovate: datasource=github-releases depName=element-hq/synapse versioning=semver extractVersion=^v(?<version>.+)$
ARG SYNAPSE_VERSION=1.143.0

# renovate: datasource=github-releases depName=matrix-org/synapse-s3-storage-provider versioning=semver extractVersion=^v(?<version>.+)$
ARG S3PROVIDER_VERSION=1.6.0

# Synapse (https://github.com/matrix-org/synapse/blob/master/INSTALL.md)
# lxml - required for previews
RUN source /app/code/env/bin/activate && \
    pip3 install --no-cache-dir matrix-synapse==v${SYNAPSE_VERSION} psycopg2-binary python-ldap matrix-synapse-ldap3 lxml publicsuffix2 git+https://github.com/matrix-org/synapse-s3-storage-provider.git@v${S3PROVIDER_VERSION} matrix-synapse[oidc]

# Updated suffix list
RUN curl -L https://publicsuffix.org/list/public_suffix_list.dat -o /app/code/env/lib/python3.12/site-packages/publicsuffix2/public_suffix_list.dat

RUN ln -sf /app/data/index.html /app/code/env/lib/python3.12/site-packages/synapse/static/index.html

ADD index.html homeserver.yaml.template start.sh /app/pkg/
ADD mas /app/pkg/mas

CMD [ "/app/pkg/start.sh" ]
