2023-06-20 20:33:43 +00:00
|
|
|
ARG SYNAPSE_VERSION=1.86.0
|
2022-02-08 16:19:40 +00:00
|
|
|
ARG HARDENED_MALLOC_VERSION=11
|
2021-06-02 17:07:35 +00:00
|
|
|
ARG UID=991
|
|
|
|
ARG GID=991
|
|
|
|
|
|
|
|
|
|
|
|
### Build Hardened Malloc
|
2022-12-04 22:09:15 +00:00
|
|
|
FROM alpine:latest as build-malloc
|
2021-06-02 17:07:35 +00:00
|
|
|
|
|
|
|
ARG HARDENED_MALLOC_VERSION
|
|
|
|
ARG CONFIG_NATIVE=false
|
2022-12-04 22:09:15 +00:00
|
|
|
ARG VARIANT=default
|
2021-06-02 17:07:35 +00:00
|
|
|
|
2023-03-10 14:51:23 +00:00
|
|
|
RUN apk -U upgrade \
|
|
|
|
&& apk --no-cache add build-base git gnupg && cd /tmp \
|
2021-06-02 17:07:35 +00:00
|
|
|
&& wget -q https://github.com/thestinger.gpg && gpg --import thestinger.gpg \
|
|
|
|
&& git clone --depth 1 --branch ${HARDENED_MALLOC_VERSION} https://github.com/GrapheneOS/hardened_malloc \
|
|
|
|
&& cd hardened_malloc && git verify-tag $(git describe --tags) \
|
2022-01-12 21:07:29 +00:00
|
|
|
&& make CONFIG_NATIVE=${CONFIG_NATIVE} VARIANT=${VARIANT}
|
2021-06-02 17:07:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
### Build Synapse
|
2022-12-04 22:09:15 +00:00
|
|
|
FROM python:alpine as builder
|
2021-06-02 17:07:35 +00:00
|
|
|
|
|
|
|
ARG SYNAPSE_VERSION
|
|
|
|
|
|
|
|
RUN apk -U upgrade \
|
2023-03-10 14:51:23 +00:00
|
|
|
&& apk --no-cache add -t build-deps \
|
2021-06-02 17:07:35 +00:00
|
|
|
build-base \
|
|
|
|
libffi-dev \
|
|
|
|
libjpeg-turbo-dev \
|
|
|
|
libxslt-dev \
|
|
|
|
linux-headers \
|
2022-12-04 22:09:15 +00:00
|
|
|
openssl-dev \
|
2021-06-02 17:07:35 +00:00
|
|
|
postgresql-dev \
|
|
|
|
rustup \
|
|
|
|
zlib-dev \
|
|
|
|
&& rustup-init -y && source $HOME/.cargo/env \
|
2022-09-06 18:15:01 +00:00
|
|
|
&& pip install --upgrade pip \
|
2021-06-02 17:07:35 +00:00
|
|
|
&& pip install --prefix="/install" --no-warn-script-location \
|
|
|
|
matrix-synapse[all]==${SYNAPSE_VERSION}
|
|
|
|
|
|
|
|
|
|
|
|
### Build Production
|
|
|
|
|
2022-12-04 22:09:15 +00:00
|
|
|
FROM python:alpine
|
2021-06-02 17:07:35 +00:00
|
|
|
|
2023-03-16 23:06:02 +00:00
|
|
|
LABEL maintainer="Thien Tran contact@tommytran.io"
|
|
|
|
|
2021-06-02 17:07:35 +00:00
|
|
|
ARG UID
|
|
|
|
ARG GID
|
|
|
|
|
|
|
|
RUN apk -U upgrade \
|
2023-03-10 14:51:23 +00:00
|
|
|
&& apk --no-cache add -t run-deps \
|
2021-06-02 17:07:35 +00:00
|
|
|
libffi \
|
|
|
|
libgcc \
|
|
|
|
libjpeg-turbo \
|
|
|
|
libstdc++ \
|
|
|
|
libxslt \
|
|
|
|
libpq \
|
2022-12-04 21:17:17 +00:00
|
|
|
openssl \
|
2021-06-02 17:07:35 +00:00
|
|
|
zlib \
|
|
|
|
tzdata \
|
|
|
|
xmlsec \
|
2022-12-04 22:09:15 +00:00
|
|
|
git \
|
2022-09-07 23:36:18 +00:00
|
|
|
curl \
|
2022-12-21 00:19:53 +00:00
|
|
|
icu-libs \
|
2021-06-02 17:07:35 +00:00
|
|
|
&& adduser -g ${GID} -u ${UID} --disabled-password --gecos "" synapse \
|
|
|
|
&& rm -rf /var/cache/apk/*
|
|
|
|
|
2022-12-04 22:09:15 +00:00
|
|
|
RUN pip install --upgrade pip \
|
|
|
|
&& pip install -e "git+https://github.com/matrix-org/mjolnir.git#egg=mjolnir&subdirectory=synapse_antispam"
|
2021-06-02 17:07:35 +00:00
|
|
|
|
2022-12-04 22:09:15 +00:00
|
|
|
COPY --from=build-malloc /tmp/hardened_malloc/out/libhardened_malloc.so /usr/local/lib/
|
2021-06-02 17:07:35 +00:00
|
|
|
COPY --from=builder /install /usr/local
|
|
|
|
COPY --chown=synapse:synapse rootfs /
|
|
|
|
|
2022-12-04 22:09:15 +00:00
|
|
|
ENV LD_PRELOAD="/usr/local/lib/libhardened_malloc.so"
|
2021-06-02 17:07:35 +00:00
|
|
|
|
|
|
|
USER synapse
|
|
|
|
|
|
|
|
VOLUME /data
|
|
|
|
|
|
|
|
EXPOSE 8008/tcp 8009/tcp 8448/tcp
|
|
|
|
|
2021-06-03 16:21:20 +00:00
|
|
|
ENTRYPOINT ["python3", "start.py"]
|
2022-09-07 23:36:18 +00:00
|
|
|
|
|
|
|
HEALTHCHECK --start-period=5s --interval=15s --timeout=5s \
|
2023-02-04 10:13:05 +00:00
|
|
|
CMD curl -fSs http://localhost:8008/health || exit 1
|