|
8 | 8 |
|
9 | 9 | ARG SYNAPSE_VERSION=latest |
10 | 10 |
|
11 | | -# first of all, we create a base image with a postgres server and database, |
12 | | -# which we can copy into the target image. For repeated rebuilds, this is |
13 | | -# much faster than apt installing postgres each time. |
14 | | -# |
15 | | -# This trick only works because (a) the Synapse image happens to have all the |
16 | | -# shared libraries that postgres wants, (b) we use a postgres image based on |
17 | | -# the same debian version as Synapse's docker image (so the versions of the |
18 | | -# shared libraries match). |
19 | | - |
20 | | -# now build the final image, based on the Synapse image. |
21 | | - |
22 | 11 | FROM matrixdotorg/synapse-workers:$SYNAPSE_VERSION |
23 | | - # copy the postgres installation over from the image we built above |
| 12 | + # First of all, we copy postgres server from the official postgres image, |
| 13 | + # since for repeated rebuilds, this is much faster than apt installing |
| 14 | + # postgres each time. |
| 15 | + |
| 16 | + # This trick only works because (a) the Synapse image happens to have all the |
| 17 | + # shared libraries that postgres wants, (b) we use a postgres image based on |
| 18 | + # the same debian version as Synapse's docker image (so the versions of the |
| 19 | + # shared libraries match). |
24 | 20 | RUN adduser --system --uid 999 postgres --home /var/lib/postgresql |
25 | 21 | COPY --from=postgres:13-bullseye /usr/lib/postgresql /usr/lib/postgresql |
26 | 22 | COPY --from=postgres:13-bullseye /usr/share/postgresql /usr/share/postgresql |
27 | 23 | RUN mkdir /var/run/postgresql && chown postgres /var/run/postgresql |
28 | 24 | ENV PATH="${PATH}:/usr/lib/postgresql/13/bin" |
29 | 25 | ENV PGDATA=/var/lib/postgresql/data |
30 | 26 |
|
31 | | - # initialise the database cluster in /var/lib/postgresql |
| 27 | + # We also initialize the database at build time, rather than runtime, so that it's faster to spin up the image. |
32 | 28 | RUN gosu postgres initdb --locale=C --encoding=UTF-8 --auth-host password |
33 | 29 |
|
34 | 30 | # Configure a password and create a database for Synapse |
|
0 commit comments