synapse/docker/Dockerfile

91 lines
1.9 KiB
Text
Raw Normal View History

2018-11-18 21:59:03 +03:00
ARG PYTHON_VERSION=3
###
### Stage 0: builder
###
2018-11-18 21:59:03 +03:00
FROM docker.io/python:${PYTHON_VERSION}-slim-stretch as builder
2018-09-10 17:02:42 +03:00
# install the OS build deps
2018-11-18 21:59:03 +03:00
RUN apt-get update && apt-get install -y \
build-essential \
libffi-dev \
2018-11-18 21:59:03 +03:00
sqlite3 \
libssl-dev \
libjpeg-dev \
libxslt1-dev \
libxml2-dev \
libpq-dev
# for ksm_preload
RUN apt-get install -y \
git \
cmake
# build things which have slow build steps, before we copy synapse, so that
# the layer can be cached.
#
# (we really just care about caching a wheel here, as the "pip install" below
# will install them again.)
RUN pip install --prefix="/install" --no-warn-script-location \
cryptography \
msgpack-python \
pillow \
pynacl
# now install synapse and all of the python deps to /install.
COPY . /synapse
RUN pip install --prefix="/install" --no-warn-script-location \
lxml \
2018-11-18 21:59:03 +03:00
psycopg2-binary \
/synapse
2018-11-18 21:59:03 +03:00
# N.B. to work, this needs:
# echo 1 > /sys/kernel/mm/ksm/run
# echo 31250 > /sys/kernel/mm/ksm/pages_to_scan # 128MB of 4KB pages at a time
# echo 10000 > /sys/kernel/mm/ksm/pages_to_scan # 40MB of pages at a time
# ...to be run in the Docker host
RUN git clone https://github.com/unbrice/ksm_preload && \
cd ksm_preload && \
cmake . && \
make && \
cp libksm_preload.so /install/lib
###
### Stage 1: runtime
###
2018-11-18 21:59:03 +03:00
FROM docker.io/python:${PYTHON_VERSION}-slim-stretch
2018-11-18 21:59:03 +03:00
RUN apt-get update && apt-get install -y \
procps \
net-tools \
iproute2 \
tcpdump \
traceroute \
mtr-tiny \
inetutils-ping \
less \
lsof
# for topologiser
RUN pip install flask
COPY --from=builder /install /usr/local
COPY ./docker/start.py /start.py
COPY ./docker/conf /conf
VOLUME ["/data"]
2018-11-18 21:59:03 +03:00
EXPOSE 8008/tcp 8448/tcp 3000/tcp
ENV LD_PRELOAD=/usr/local/lib/libksm_preload.so
# default is 32768 (8 4KB pages)
ENV KSMP_MERGE_THRESHOLD=16384
2018-02-04 14:55:20 +03:00
ENTRYPOINT ["/start.py"]