tommytran732-Synapse-Docker/Dockerfile

89 lines
2.1 KiB
Docker
Raw Normal View History

2022-12-20 19:13:21 -05:00
ARG SYNAPSE_VERSION=1.74.0
2022-11-18 06:49:12 -05:00
ARG PYTHON_VERSION=3.11
2022-12-04 16:11:41 -05:00
ARG ALPINE_VERSION=3.17
ARG HARDENED_MALLOC_VERSION=11
2021-06-02 13:07:35 -04:00
ARG UID=991
ARG GID=991
### Build Hardened Malloc
FROM alpine:${ALPINE_VERSION} as build-malloc
ARG HARDENED_MALLOC_VERSION
ARG CONFIG_NATIVE=false
ARG VARIANT=light
2021-06-02 13:07:35 -04:00
RUN apk --no-cache add build-base git gnupg && cd /tmp \
&& 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) \
&& make CONFIG_NATIVE=${CONFIG_NATIVE} VARIANT=${VARIANT}
2021-06-02 13:07:35 -04:00
### Build Synapse
ARG ALPINE_VERSION
FROM python:${PYTHON_VERSION}-alpine${ALPINE_VERSION} as builder
ARG SYNAPSE_VERSION
RUN apk -U upgrade \
&& apk add -t build-deps \
build-base \
libffi-dev \
libjpeg-turbo-dev \
libxslt-dev \
linux-headers \
2022-12-04 16:17:17 -05:00
openssl-dev \
2021-06-02 13:07:35 -04:00
postgresql-dev \
rustup \
zlib-dev \
&& rustup-init -y && source $HOME/.cargo/env \
2022-09-06 14:15:01 -04:00
&& pip install --upgrade pip \
2021-06-02 13:07:35 -04:00
&& pip install --prefix="/install" --no-warn-script-location \
matrix-synapse[all]==${SYNAPSE_VERSION}
### Build Production
ARG ALPINE_VERSION
ARG PYTHON_VERSION
FROM python:${PYTHON_VERSION}-alpine${ALPINE_VERSION}
ARG UID
ARG GID
RUN apk -U upgrade \
&& apk add -t run-deps \
libffi \
libgcc \
libjpeg-turbo \
libstdc++ \
libxslt \
libpq \
2022-12-04 16:17:17 -05:00
openssl \
2021-06-02 13:07:35 -04:00
zlib \
tzdata \
xmlsec \
curl \
2022-12-20 19:19:53 -05:00
icu-libs \
2021-06-02 13:07:35 -04:00
&& adduser -g ${GID} -u ${UID} --disabled-password --gecos "" synapse \
&& rm -rf /var/cache/apk/*
COPY --from=build-malloc /tmp/hardened_malloc/out-light/libhardened_malloc-light.so /usr/local/lib/
2021-06-02 13:07:35 -04:00
COPY --from=builder /install /usr/local
COPY --chown=synapse:synapse rootfs /
ENV LD_PRELOAD="/usr/local/lib/libhardened_malloc-light.so"
2021-06-02 13:07:35 -04:00
USER synapse
VOLUME /data
EXPOSE 8008/tcp 8009/tcp 8448/tcp
2021-06-03 12:21:20 -04:00
ENTRYPOINT ["python3", "start.py"]
HEALTHCHECK --start-period=5s --interval=15s --timeout=5s \
CMD curl -fSs http://localhost:8008/health || exit 1