mirror of
https://github.com/element-hq/synapse.git
synced 2024-12-19 17:56:19 +03:00
meshsim Dockerfile
This commit is contained in:
parent
dad89a4902
commit
fe3b9d085f
6 changed files with 62 additions and 26 deletions
|
@ -1,21 +1,26 @@
|
|||
ARG PYTHON_VERSION=2
|
||||
ARG PYTHON_VERSION=3
|
||||
|
||||
###
|
||||
### Stage 0: builder
|
||||
###
|
||||
FROM docker.io/python:${PYTHON_VERSION}-alpine3.8 as builder
|
||||
FROM docker.io/python:${PYTHON_VERSION}-slim-stretch as builder
|
||||
|
||||
# install the OS build deps
|
||||
|
||||
RUN apk add \
|
||||
build-base \
|
||||
RUN apt-get update && apt-get install -y \
|
||||
build-essential \
|
||||
libffi-dev \
|
||||
libjpeg-turbo-dev \
|
||||
libressl-dev \
|
||||
libxslt-dev \
|
||||
linux-headers \
|
||||
postgresql-dev \
|
||||
zlib-dev
|
||||
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.
|
||||
|
@ -34,23 +39,40 @@ RUN pip install --prefix="/install" --no-warn-script-location \
|
|||
COPY . /synapse
|
||||
RUN pip install --prefix="/install" --no-warn-script-location \
|
||||
lxml \
|
||||
psycopg2 \
|
||||
psycopg2-binary \
|
||||
/synapse
|
||||
|
||||
# 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
|
||||
###
|
||||
|
||||
FROM docker.io/python:${PYTHON_VERSION}-alpine3.8
|
||||
FROM docker.io/python:${PYTHON_VERSION}-slim-stretch
|
||||
|
||||
RUN apk add --no-cache --virtual .runtime_deps \
|
||||
libffi \
|
||||
libjpeg-turbo \
|
||||
libressl \
|
||||
libxslt \
|
||||
libpq \
|
||||
zlib \
|
||||
su-exec
|
||||
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
|
||||
|
@ -58,6 +80,11 @@ COPY ./docker/conf /conf
|
|||
|
||||
VOLUME ["/data"]
|
||||
|
||||
EXPOSE 8008/tcp 8448/tcp
|
||||
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
|
||||
|
||||
ENTRYPOINT ["/start.py"]
|
||||
|
|
|
@ -55,7 +55,7 @@ database:
|
|||
database: "{{ POSTGRES_DB or "synapse" }}"
|
||||
host: "{{ POSTGRES_HOST or "db" }}"
|
||||
port: "{{ POSTGRES_PORT or "5432" }}"
|
||||
cp_min: 5
|
||||
cp_min: 1
|
||||
cp_max: 10
|
||||
{% else %}
|
||||
database:
|
||||
|
|
|
@ -6,6 +6,7 @@ import sys
|
|||
import subprocess
|
||||
import glob
|
||||
import codecs
|
||||
import time
|
||||
|
||||
# Utility functions
|
||||
convert = lambda src, dst, environ: open(dst, "w").write(jinja2.Template(open(src).read()).render(**environ))
|
||||
|
@ -31,6 +32,10 @@ def generate_secrets(environ, secrets):
|
|||
# Prepare the configuration
|
||||
mode = sys.argv[1] if len(sys.argv) > 1 else None
|
||||
environ = os.environ.copy()
|
||||
|
||||
for e in environ:
|
||||
print("%s:%s" % (e, environ[e]))
|
||||
|
||||
ownership = "{}:{}".format(environ.get("UID", 991), environ.get("GID", 991))
|
||||
args = ["python", "-m", "synapse.app.homeserver"]
|
||||
|
||||
|
@ -64,4 +69,8 @@ else:
|
|||
args += ["--config-path", "/compiled/homeserver.yaml"]
|
||||
# Generate missing keys and start synapse
|
||||
subprocess.check_output(args + ["--generate-keys"])
|
||||
os.execv("/sbin/su-exec", ["su-exec", ownership] + args)
|
||||
|
||||
os.system("(sleep 5; /usr/local/bin/register_new_matrix_user -u matthew -p isildur -c /compiled/homeserver.yaml -a) &");
|
||||
|
||||
os.execv("/usr/local/bin/python", args)
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ def check(event, auth_events, do_sig_check=True, do_size_check=True):
|
|||
AuthError if the checks fail
|
||||
|
||||
Returns:
|
||||
if the auth checks pass.
|
||||
if the auth checks pass.
|
||||
"""
|
||||
if do_size_check:
|
||||
_check_size_limits(event)
|
||||
|
|
|
@ -347,7 +347,7 @@ class PresenceHandler(object):
|
|||
"""Checks the presence of users that have timed out and updates as
|
||||
appropriate.
|
||||
"""
|
||||
logger.info("Handling presence timeouts")
|
||||
#logger.info("Handling presence timeouts")
|
||||
now = self.clock.time_msec()
|
||||
|
||||
try:
|
||||
|
|
|
@ -86,7 +86,7 @@ class TypingHandler(object):
|
|||
self._room_typing = {}
|
||||
|
||||
def _handle_timeouts(self):
|
||||
logger.info("Checking for typing timeouts")
|
||||
#logger.info("Checking for typing timeouts")
|
||||
|
||||
now = self.clock.time_msec()
|
||||
|
||||
|
|
Loading…
Reference in a new issue