|
1 | 1 | # syntax=docker/dockerfile:1
|
2 |
| -# This dockerfile builds on top of 'docker/Dockerfile-workers' in matrix-org/synapse |
| 2 | +# This dockerfile builds on top of 'docker/Dockerfile-workers' in element.-hq/synapse |
3 | 3 | # by including a built-in postgres instance, as well as setting up the homeserver so
|
4 | 4 | # that it is ready for testing via Complement.
|
5 | 5 | #
|
6 | 6 | # Instructions for building this image from those it depends on is detailed in this guide:
|
7 |
| -# https://github.com/matrix-org/synapse/blob/develop/docker/README-testing.md#testing-with-postgresql-and-single-or-multi-process-synapse |
| 7 | +# https://github.com/element.-hq/synapse/blob/develop/docker/README-testing.md#testing-with-postgresql-and-single-or-multi-process-synapse |
8 | 8 |
|
9 | 9 | ARG SYNAPSE_VERSION=latest
|
10 | 10 | # This is an intermediate image, to be built locally (not pulled from a registry).
|
11 | 11 | ARG FROM=matrixdotorg/synapse-workers:$SYNAPSE_VERSION
|
12 | 12 |
|
13 | 13 | FROM $FROM
|
14 |
| - # First of all, we copy postgres server from the official postgres image, |
15 |
| - # since for repeated rebuilds, this is much faster than apt installing |
16 |
| - # postgres each time. |
17 |
| - |
18 |
| - # This trick only works because (a) the Synapse image happens to have all the |
19 |
| - # shared libraries that postgres wants, (b) we use a postgres image based on |
20 |
| - # the same debian version as Synapse's docker image (so the versions of the |
21 |
| - # shared libraries match). |
22 |
| - RUN adduser --system --uid 999 postgres --home /var/lib/postgresql |
23 |
| - COPY --from=docker.io/library/postgres:13-bookworm /usr/lib/postgresql /usr/lib/postgresql |
24 |
| - COPY --from=docker.io/library/postgres:13-bookworm /usr/share/postgresql /usr/share/postgresql |
25 |
| - RUN mkdir /var/run/postgresql && chown postgres /var/run/postgresql |
26 |
| - ENV PATH="${PATH}:/usr/lib/postgresql/13/bin" |
27 |
| - ENV PGDATA=/var/lib/postgresql/data |
28 |
| - |
29 |
| - # We also initialize the database at build time, rather than runtime, so that it's faster to spin up the image. |
30 |
| - RUN gosu postgres initdb --locale=C --encoding=UTF-8 --auth-host password |
31 |
| - |
32 |
| - # Configure a password and create a database for Synapse |
33 |
| - RUN echo "ALTER USER postgres PASSWORD 'somesecret'" | gosu postgres postgres --single |
34 |
| - RUN echo "CREATE DATABASE synapse" | gosu postgres postgres --single |
35 |
| - |
36 |
| - # Extend the shared homeserver config to disable rate-limiting, |
37 |
| - # set Complement's static shared secret, enable registration, amongst other |
38 |
| - # tweaks to get Synapse ready for testing. |
39 |
| - # To do this, we copy the old template out of the way and then include it |
40 |
| - # with Jinja2. |
41 |
| - RUN mv /conf/shared.yaml.j2 /conf/shared-orig.yaml.j2 |
42 |
| - COPY conf/workers-shared-extra.yaml.j2 /conf/shared.yaml.j2 |
43 |
| - |
44 |
| - WORKDIR /data |
45 |
| - |
46 |
| - COPY conf/postgres.supervisord.conf /etc/supervisor/conf.d/postgres.conf |
47 |
| - |
48 |
| - # Copy the entrypoint |
49 |
| - COPY conf/start_for_complement.sh / |
50 |
| - |
51 |
| - # Expose nginx's listener ports |
52 |
| - EXPOSE 8008 8448 |
53 |
| - |
54 |
| - ENTRYPOINT ["/start_for_complement.sh"] |
55 |
| - |
56 |
| - # Update the healthcheck to have a shorter check interval |
57 |
| - HEALTHCHECK --start-period=5s --interval=1s --timeout=1s \ |
58 |
| - CMD /bin/sh /healthcheck.sh |
| 14 | +# First of all, we copy postgres server from the official postgres image, |
| 15 | +# since for repeated rebuilds, this is much faster than apt installing |
| 16 | +# postgres each time. |
| 17 | + |
| 18 | +# This trick only works because (a) the Synapse image happens to have all the |
| 19 | +# shared libraries that postgres wants, (b) we use a postgres image based on |
| 20 | +# the same debian version as Synapse's docker image (so the versions of the |
| 21 | +# shared libraries match). |
| 22 | +RUN adduser --system --uid 999 postgres --home /var/lib/postgresql |
| 23 | +COPY --from=docker.io/library/postgres:13-bookworm /usr/lib/postgresql /usr/lib/postgresql |
| 24 | +COPY --from=docker.io/library/postgres:13-bookworm /usr/share/postgresql /usr/share/postgresql |
| 25 | +RUN mkdir /var/run/postgresql && chown postgres /var/run/postgresql |
| 26 | +ENV PATH="${PATH}:/usr/lib/postgresql/13/bin" |
| 27 | +ENV PGDATA=/var/lib/postgresql/data |
| 28 | + |
| 29 | +# We also initialize the database at build time, rather than runtime, so that it's faster to spin up the image. |
| 30 | +RUN gosu postgres initdb --locale=C --encoding=UTF-8 --auth-host password |
| 31 | + |
| 32 | +# Configure a password and create a database for Synapse |
| 33 | +RUN echo "ALTER USER postgres PASSWORD 'somesecret'" | gosu postgres postgres --single |
| 34 | +RUN echo "CREATE DATABASE synapse" | gosu postgres postgres --single |
| 35 | + |
| 36 | +# Extend the shared homeserver config to disable rate-limiting, |
| 37 | +# set Complement's static shared secret, enable registration, amongst other |
| 38 | +# tweaks to get Synapse ready for testing. |
| 39 | +# To do this, we copy the old template out of the way and then include it |
| 40 | +# with Jinja2. |
| 41 | +RUN mv /conf/shared.yaml.j2 /conf/shared-orig.yaml.j2 |
| 42 | +COPY conf/workers-shared-extra.yaml.j2 /conf/shared.yaml.j2 |
| 43 | + |
| 44 | +WORKDIR /data |
| 45 | + |
| 46 | +COPY conf/postgres.supervisord.conf /etc/supervisor/conf.d/postgres.conf |
| 47 | + |
| 48 | +# Copy the entrypoint |
| 49 | +COPY conf/start_for_complement.sh / |
| 50 | + |
| 51 | +# Expose nginx's listener ports |
| 52 | +EXPOSE 8008 8448 |
| 53 | + |
| 54 | +ENTRYPOINT ["/start_for_complement.sh"] |
| 55 | + |
| 56 | +# Update the healthcheck to have a shorter check interval |
| 57 | +HEALTHCHECK --start-period=5s --interval=1s --timeout=1s \ |
| 58 | + CMD /bin/sh /healthcheck.sh |
0 commit comments