camptocamp / docker-qgis-server

All that is needed to generate a proper QGIS server image
GNU General Public License v2.0
40 stars 8 forks source link
geospatial

Docker image for QGIS server

Usage

The Docker container needs to have access to all files of the QGIS project to be published. Either you create another image to add the files or you inject them using a volume. For example, if your QGIS project is stored in ./qgis/project.qgz:

docker run --detach --publish=8380:80 --volume=${PWD}/qgis:/etc/qgisserver camptocamp/qgis-server

With the previous command, you'll get to your server with this URL: http://localhost:8380/?MAP=/etc/qgisserver/project.qgz&SERVICE=WMS&REQUEST=GetCapabilities

Tuning

You can use the following variables (-e option in docker run):

See also QGIS server documentation

Fonts present in the /etc/qgisserver/fonts directory will be installed and thus usable by QGIS.

Get a stack trace in case of segfault

To get a good stack trace you should use the -debug image.

Run the querty that makes the server crash, then:

Open a bash as root on the container with something like: docker compose exec --user=root qgisserver bash, then:

CORE_FILENAME=$(ls -tr1 /tmp/|grep core|tail -n 1)
gdb /usr/local/bin/qgis_mapserv.fcgi /tmp/${CORE_FILENAME}

The command bt will give you the stack trace.

Running the client

If you want to edit a project file, you can run the client from a Linux machine with the following command:

docker run --rm -ti --env=DISPLAY=unix${DISPLAY} --volume=/tmp/.X11-unix:/tmp/.X11-unix --volume=${HOME}:${HOME} camptocamp/qgis-server:master-desktop

Changelog

QGIS 3.22

We removed the default values for the following environment variables to better fit with the QGIS documentation:

Contributing

Install the pre-commit hooks:

pip install pre-commit
pre-commit install --allow-missing-config