diff options
author | Mathieu Velten <mathieuv@matrix.org> | 2022-09-14 17:00:09 +0200 |
---|---|---|
committer | Mathieu Velten <mathieuv@matrix.org> | 2022-09-14 17:18:35 +0200 |
commit | f2352314925303c34ffee0d6961046eb53eb57d3 (patch) | |
tree | 2877ef93a34a791ba990ab785bf9bcb3d60f0141 | |
parent | Fix bug in device list caching when remote users leave rooms (#13749) (diff) | |
download | synapse-github/mv/complement-pg-data.tar.xz |
complement: move PG data outside of the container storage github/mv/complement-pg-data mv/complement-pg-data
Signed-off-by: Mathieu Velten <mathieuv@matrix.org>
-rw-r--r-- | changelog.d/13806.misc | 1 | ||||
-rw-r--r-- | docker/complement/Dockerfile | 15 | ||||
-rwxr-xr-x | docker/complement/conf/start_for_complement.sh | 8 | ||||
-rwxr-xr-x | scripts-dev/complement.sh | 9 |
4 files changed, 21 insertions, 12 deletions
diff --git a/changelog.d/13806.misc b/changelog.d/13806.misc new file mode 100644 index 0000000000..6f16782586 --- /dev/null +++ b/changelog.d/13806.misc @@ -0,0 +1 @@ +complement tests: put postgres data folder on an host path on /tmp that we bindmount, outside of the container storage that can be quite slow. diff --git a/docker/complement/Dockerfile b/docker/complement/Dockerfile index 3cfff19f9a..3bfa66ccd4 100644 --- a/docker/complement/Dockerfile +++ b/docker/complement/Dockerfile @@ -17,25 +17,16 @@ ARG SYNAPSE_VERSION=latest # the same debian version as Synapse's docker image (so the versions of the # shared libraries match). -FROM postgres:13-bullseye AS postgres_base - # initialise the database cluster in /var/lib/postgresql - RUN gosu postgres initdb --locale=C --encoding=UTF-8 --auth-host password - - # Configure a password and create a database for Synapse - RUN echo "ALTER USER postgres PASSWORD 'somesecret'" | gosu postgres postgres --single - RUN echo "CREATE DATABASE synapse" | gosu postgres postgres --single - # now build the final image, based on the Synapse image. FROM matrixdotorg/synapse-workers:$SYNAPSE_VERSION # copy the postgres installation over from the image we built above RUN adduser --system --uid 999 postgres --home /var/lib/postgresql - COPY --from=postgres_base /var/lib/postgresql /var/lib/postgresql - COPY --from=postgres_base /usr/lib/postgresql /usr/lib/postgresql - COPY --from=postgres_base /usr/share/postgresql /usr/share/postgresql + COPY --from=postgres:13-bullseye /usr/lib/postgresql /usr/lib/postgresql + COPY --from=postgres:13-bullseye /usr/share/postgresql /usr/share/postgresql RUN mkdir /var/run/postgresql && chown postgres /var/run/postgresql ENV PATH="${PATH}:/usr/lib/postgresql/13/bin" - ENV PGDATA=/var/lib/postgresql/data + ENV PGDATA=/var/lib/postgresql/data/main # Extend the shared homeserver config to disable rate-limiting, # set Complement's static shared secret, enable registration, amongst other diff --git a/docker/complement/conf/start_for_complement.sh b/docker/complement/conf/start_for_complement.sh index cc6482f763..4fd12b469e 100755 --- a/docker/complement/conf/start_for_complement.sh +++ b/docker/complement/conf/start_for_complement.sh @@ -25,8 +25,16 @@ case "$SYNAPSE_COMPLEMENT_DATABASE" in # Set postgres authentication details which will be placed in the homeserver config file export POSTGRES_PASSWORD=somesecret export POSTGRES_USER=postgres + export POSTGRES_HOST=localhost + if [ ! -f "$PGDATA/PG_VERSION" ]; then + gosu postgres initdb --locale=C --encoding=UTF-8 --auth-host password + + echo "ALTER USER postgres PASSWORD 'somesecret'" | gosu postgres postgres --single + echo "CREATE DATABASE synapse" | gosu postgres postgres --single + fi + # configure supervisord to start postgres export START_POSTGRES=true ;; diff --git a/scripts-dev/complement.sh b/scripts-dev/complement.sh index eab23f18f1..857748d7c2 100755 --- a/scripts-dev/complement.sh +++ b/scripts-dev/complement.sh @@ -122,7 +122,14 @@ if [ -n "$skip_complement_run" ]; then exit fi +PG_DATA_FOLDER=/tmp/postgres-data + +rm -rf $PG_DATA_FOLDER +mkdir -p $PG_DATA_FOLDER +chmod 777 $PG_DATA_FOLDER + export COMPLEMENT_BASE_IMAGE=complement-synapse +export COMPLEMENT_HOST_MOUNTS=$PG_DATA_FOLDER:/var/lib/postgresql/data extra_test_args=() @@ -178,3 +185,5 @@ echo "Images built; running complement" cd "$COMPLEMENT_DIR" go test -v -tags $test_tags -count=1 "${extra_test_args[@]}" "$@" ./tests/... + +rm -rf $PG_DATA_FOLDER |