2018-11-18 21:59:03 +03:00
|
|
|
ARG PYTHON_VERSION=3
|
2018-02-03 22:18:36 +03:00
|
|
|
|
2018-10-01 14:29:17 +03:00
|
|
|
###
|
|
|
|
### 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
|
|
|
|
2018-10-01 14:29:17 +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 \
|
2018-07-17 10:07:03 +03:00
|
|
|
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
|
2018-10-01 14:29:17 +03:00
|
|
|
|
|
|
|
# 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 \
|
2018-07-17 10:07:03 +03:00
|
|
|
lxml \
|
2018-11-18 21:59:03 +03:00
|
|
|
psycopg2-binary \
|
2018-10-01 14:29:17 +03:00
|
|
|
/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
|
|
|
|
|
2018-10-01 14:29:17 +03:00
|
|
|
###
|
|
|
|
### Stage 1: runtime
|
|
|
|
###
|
|
|
|
|
2018-11-18 21:59:03 +03:00
|
|
|
FROM docker.io/python:${PYTHON_VERSION}-slim-stretch
|
2018-10-01 14:29:17 +03:00
|
|
|
|
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 \
|
2018-11-22 18:10:19 +03:00
|
|
|
lsof \
|
2018-11-27 03:55:04 +03:00
|
|
|
supervisor \
|
|
|
|
netcat
|
2018-11-18 21:59:03 +03:00
|
|
|
|
|
|
|
# for topologiser
|
|
|
|
RUN pip install flask
|
2018-10-01 14:29:17 +03:00
|
|
|
|
|
|
|
COPY --from=builder /install /usr/local
|
|
|
|
COPY ./docker/start.py /start.py
|
|
|
|
COPY ./docker/conf /conf
|
2018-11-23 13:06:28 +03:00
|
|
|
COPY ./docker/proxy/proxy /proxy/proxy
|
|
|
|
COPY ./docker/proxy/maps /proxy/maps
|
2018-11-22 18:10:19 +03:00
|
|
|
COPY ./docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
2018-10-01 14:29:17 +03:00
|
|
|
|
2018-02-03 22:18:36 +03:00
|
|
|
VOLUME ["/data"]
|
|
|
|
|
2018-11-22 18:10:19 +03:00
|
|
|
EXPOSE 8008/tcp 8448/tcp 3000/tcp 5683/udp
|
2018-11-18 21:59:03 +03:00
|
|
|
|
|
|
|
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
|
|
|
|
2018-11-22 18:10:19 +03:00
|
|
|
ENTRYPOINT ["/usr/bin/supervisord"]
|