qgis / qgis-docker

Official Docker image for QGIS Server and Desktop
GNU Affero General Public License v3.0
67 stars 21 forks source link

Support pgservice.conf #41

Closed olivierdalang closed 3 years ago

olivierdalang commented 3 years ago

Hi !

Using pgservice.conf is good practice, as it avoids having to hardcode the postgres connection info in the project file, making the project file much more portable (you can use the same locally and in the server, and distribute it without leaking postgres passwords).

Unfortunately, it seems it's not supported with this image.

Mounting the file under /var/lib/qgis/.pgservice.conf (or somewhere else by specifying the PGSERVICEFILE env var) as per postgres's docs does not work with following error :

12:45:56 WARNING PostGIS[26]: Connection to database failed`
definition of service "myservice" not found.

To make it work, one has to add a line like fastcgi_param PGSERVICEFILE /io/.pg_service.conf; next to https://github.com/gem/oq-qgis-server/blob/master/conf/qgis-server-nginx.conf#L98, which is annoying as it requires overwriting the whole config file.

Thanks for this otherwise great image !

mbernasocchi commented 3 years ago

@olivierdalang actually there is an easy workaround, could you test and if it works add it to the documentation? you need to mount the file to the default pg_service location -v ./myconf/pg_service.conf:/etc/postgresql-common/pg_service.conf:ro