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

Unable to build complement-synapse Docker image #13319

Closed
uhoreg opened this issue Jul 18, 2022 · 3 comments · Fixed by #13338
Closed

Unable to build complement-synapse Docker image #13319

uhoreg opened this issue Jul 18, 2022 · 3 comments · Fixed by #13338
Labels
A-Docs things relating to the documentation T-Task Refactoring, removal, replacement, enabling or disabling functionality, other engineering tasks.

Comments

@uhoreg
Copy link
Member

uhoreg commented Jul 18, 2022

I tried to build the complement-synapse image, as described in docker/README-testing.md, but when I ran docker build -t complement-synapse -f docker/complement/Dockerfile docker/complement, it failed, saying:

...
Step 4/21 : RUN echo "ALTER USER postgres PASSWORD 'somesecret'" | gosu postgres postgres --single
 ---> Running in cbf9ce044882
postgres: could not access the server configuration file "/var/lib/postgresql/data/postgresql.conf": No such file or directory
The command '/bin/sh -c echo "ALTER USER postgres PASSWORD 'somesecret'" | gosu postgres postgres --single' returned a non-zero code: 1

It appears that it did not persist the changes to /var/lib/postgresql/data that were made in the previous Dockerfile step did not get persisted, and so /var/lib/postgresql/data remains empty. This seems to be because /var/lib/postgresql/data is marked as a VOLUME in the postgres image, which means that changes to that directory are discarded.

If I combine the three RUN statements in the postgres section of the Dockerfile into a single line, then the build "succeeds", but of course the /var/lib/postgresql/data directory is still empty in the resulting image.

@uhoreg
Copy link
Member Author

uhoreg commented Jul 18, 2022

Using scripts-dev/complement.sh seems to build the image correctly, though.

@richvdh
Copy link
Member

richvdh commented Jul 19, 2022

I think the difference is the use of BuildKit rather than legacy docker build. For some reason BuildKit includes /var/lib/postgresql/data in the image, so you need to set DOCKER_BUILDKIT=1 when building the image, and that should be mentioned in docker/README-testing.md. But you need to do that when building the other two images as well, so I'm surprised that you got this far without it.

A possibly-more-correct workaround would be to have the postgres_base image construct the database in a different directory.

@uhoreg
Copy link
Member Author

uhoreg commented Jul 19, 2022

I originally used the matrixdotorg/synapse image from Docker hub, so that's why I was able to get that image without DOCKER_BUILDKIT=1.

@babolivier babolivier added A-Docs things relating to the documentation T-Task Refactoring, removal, replacement, enabling or disabling functionality, other engineering tasks. labels Jul 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Docs things relating to the documentation T-Task Refactoring, removal, replacement, enabling or disabling functionality, other engineering tasks.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants