Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 384dca5

Browse files
author
Mathieu Velten
authored
complement: init postgres DB directly inside the target image (#13819)
Doing so in the base postgres image doesn't work with buildah because changes in a declared VOLUME in the Dockerfile is supposed to be discarded, cf https://docs.docker.com/engine/reference/builder/#volume Signed-off-by: Mathieu Velten <[email protected]>
1 parent 74f60ce commit 384dca5

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

changelog.d/13819.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
complement: init postgres DB directly inside the target image instead of the base postgres image to fix building using Buildah.

docker/complement/Dockerfile

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,24 @@ ARG SYNAPSE_VERSION=latest
1717
# the same debian version as Synapse's docker image (so the versions of the
1818
# shared libraries match).
1919

20-
FROM postgres:13-bullseye AS postgres_base
21-
# initialise the database cluster in /var/lib/postgresql
22-
RUN gosu postgres initdb --locale=C --encoding=UTF-8 --auth-host password
23-
24-
# Configure a password and create a database for Synapse
25-
RUN echo "ALTER USER postgres PASSWORD 'somesecret'" | gosu postgres postgres --single
26-
RUN echo "CREATE DATABASE synapse" | gosu postgres postgres --single
27-
2820
# now build the final image, based on the Synapse image.
2921

3022
FROM matrixdotorg/synapse-workers:$SYNAPSE_VERSION
3123
# copy the postgres installation over from the image we built above
3224
RUN adduser --system --uid 999 postgres --home /var/lib/postgresql
33-
COPY --from=postgres_base /var/lib/postgresql /var/lib/postgresql
34-
COPY --from=postgres_base /usr/lib/postgresql /usr/lib/postgresql
35-
COPY --from=postgres_base /usr/share/postgresql /usr/share/postgresql
25+
COPY --from=postgres:13-bullseye /usr/lib/postgresql /usr/lib/postgresql
26+
COPY --from=postgres:13-bullseye /usr/share/postgresql /usr/share/postgresql
3627
RUN mkdir /var/run/postgresql && chown postgres /var/run/postgresql
3728
ENV PATH="${PATH}:/usr/lib/postgresql/13/bin"
3829
ENV PGDATA=/var/lib/postgresql/data
3930

31+
# initialise the database cluster in /var/lib/postgresql
32+
RUN gosu postgres initdb --locale=C --encoding=UTF-8 --auth-host password
33+
34+
# Configure a password and create a database for Synapse
35+
RUN echo "ALTER USER postgres PASSWORD 'somesecret'" | gosu postgres postgres --single
36+
RUN echo "CREATE DATABASE synapse" | gosu postgres postgres --single
37+
4038
# Extend the shared homeserver config to disable rate-limiting,
4139
# set Complement's static shared secret, enable registration, amongst other
4240
# tweaks to get Synapse ready for testing.

0 commit comments

Comments
 (0)