|
| 1 | +# This dockerfile builds on top of 'docker/Dockerfile-worker' in matrix-org/synapse |
| 2 | +# by including a built-in postgres instance, as well as setting up the homeserver so |
| 3 | +# that it is ready for testing via Complement. |
| 4 | +# |
| 5 | +# Instructions for building this image from those it depends on is detailed in this guide: |
| 6 | +# https://github.com/matrix-org/synapse/blob/develop/docker/README-testing.md#testing-with-postgresql-and-single-or-multi-process-synapse |
| 7 | +FROM matrixdotorg/synapse-workers |
| 8 | + |
| 9 | +# Download a caddy server to stand in front of nginx and terminate TLS using Complement's |
| 10 | +# custom CA. |
| 11 | +# We include this near the top of the file in order to cache the result. |
| 12 | +RUN curl -OL "https://github.com/caddyserver/caddy/releases/download/v2.3.0/caddy_2.3.0_linux_amd64.tar.gz" && \ |
| 13 | + tar xzf caddy_2.3.0_linux_amd64.tar.gz && rm caddy_2.3.0_linux_amd64.tar.gz && mv caddy /root |
| 14 | + |
| 15 | +# Install postgresql |
| 16 | +RUN apt-get update |
| 17 | +RUN apt-get install -y postgresql |
| 18 | + |
| 19 | +# Configure a user and create a database for Synapse |
| 20 | +RUN pg_ctlcluster 13 main start && su postgres -c "echo \ |
| 21 | + \"ALTER USER postgres PASSWORD 'somesecret'; \ |
| 22 | + CREATE DATABASE synapse \ |
| 23 | + ENCODING 'UTF8' \ |
| 24 | + LC_COLLATE='C' \ |
| 25 | + LC_CTYPE='C' \ |
| 26 | + template=template0;\" | psql" && pg_ctlcluster 13 main stop |
| 27 | + |
| 28 | +# Modify the shared homeserver config with postgres support, certificate setup |
| 29 | +# and the disabling of rate-limiting |
| 30 | +COPY conf-workers/workers-shared.yaml /conf/workers/shared.yaml |
| 31 | + |
| 32 | +WORKDIR /data |
| 33 | + |
| 34 | +# Copy the caddy config |
| 35 | +COPY conf-workers/caddy.complement.json /root/caddy.json |
| 36 | + |
| 37 | +# Expose caddy's listener ports |
| 38 | +EXPOSE 8008 8448 |
| 39 | + |
| 40 | +ENTRYPOINT \ |
| 41 | + # Replace the server name in the caddy config |
| 42 | + sed -i "s/{{ server_name }}/${SERVER_NAME}/g" /root/caddy.json && \ |
| 43 | + # Start postgres |
| 44 | + pg_ctlcluster 13 main start 2>&1 && \ |
| 45 | + # Start caddy |
| 46 | + /root/caddy start --config /root/caddy.json 2>&1 && \ |
| 47 | + # Set the server name of the homeserver |
| 48 | + SYNAPSE_SERVER_NAME=${SERVER_NAME} \ |
| 49 | + # No need to report stats here |
| 50 | + SYNAPSE_REPORT_STATS=no \ |
| 51 | + # Set postgres authentication details which will be placed in the homeserver config file |
| 52 | + POSTGRES_PASSWORD=somesecret POSTGRES_USER=postgres POSTGRES_HOST=localhost \ |
| 53 | + # Specify the workers to test with |
| 54 | + SYNAPSE_WORKER_TYPES="\ |
| 55 | + event_persister, \ |
| 56 | + event_persister, \ |
| 57 | + background_worker, \ |
| 58 | + frontend_proxy, \ |
| 59 | + event_creator, \ |
| 60 | + user_dir, \ |
| 61 | + media_repository, \ |
| 62 | + federation_inbound, \ |
| 63 | + federation_reader, \ |
| 64 | + federation_sender, \ |
| 65 | + synchrotron, \ |
| 66 | + appservice, \ |
| 67 | + pusher" \ |
| 68 | + # Run the script that writes the necessary config files and starts supervisord, which in turn |
| 69 | + # starts everything else |
| 70 | + /configure_workers_and_start.py |
| 71 | + |
| 72 | +HEALTHCHECK --start-period=5s --interval=1s --timeout=1s \ |
| 73 | + CMD /bin/sh /healthcheck.sh |
0 commit comments