Deployment of server application in Docker containers
Gisquick application is split into 3 services running in Docker containers:
- QGIS server (
- Django Application served with Gunicorn (
- Nginx Server (
Docker images can be put together using
command. The command reads configuration file in YAML
language. Sample configuration of Gisquick services is shown below.
.. literalinclude:: ../../_static/docker/example.docker-compose.yml :language: python :emphasize-lines: 7,9,17,18,22,23,37,38,41,43 :linenos:
It is important to set up shared directories mounted by Docker containers
as volumes. QGIS Server requires setting up :file:`publish`
directory which is used for published Gisquick projects (see line
7). Django Application stores SQLite database in :file:`data`
17), tile cache is managed in :file:`media`
18). SSL certificates used by Nginx Web Server
are stored in directory :file:`letsencrypt` (line
QGIS server is running in this case on port 90 (see line
web server on default port for HTTPS protocol 443 (line
Before composing Docker images, shared directories must be created on host machine. In shown example all directories are located in the same folder as :file:`docker-compose.yml` file.
$ mkdir -p _data/publish _data/media _data/data _data/etc/letsencrypt/live
Directory for SSL certificates is defined by :envvar:`NGINX_HOST`
environmental variable (see line
43) located in :file:`live`
directory. For sample configuration, the SSL certificates will be
located in :file:`./_data/etc/letsencrypt/live/server`
directory. See example of creating self-signed certificate below.
$ mkdir -p _data/etc/letsencrypt/live/server $ openssl req -x509 -nodes -days 3650 -newkey rsa:2048 \ -keyout _data/etc/letsencrypt/live/server/privkey.pem \ -out _data/etc/letsencrypt/live/server/fullchain.pem \ -subj "/C=CZ/ST=Prague/L=Prague/O=Gisquick/OU=IT Department/CN=server"
There are more environmental variables which can be defined. Django container allows to set up:
- :envvar:`DJANGO_GISQUICK_UPLOAD_MAX_SIZE` - max. size of uploaded projects (string)
- :envvar:`DJANGO_DEBUG` -
False(bool) to enable/disable debug messages
- :envvar:`DJANGO_ACCOUNT_ACTIVATION_DAYS` - number of days (int) for activation of user account
Example of additional configuration:
django: environment: - DJANGO_GISQUICK_UPLOAD_MAX_SIZE='10M' - DJANGO_DEBUG=True - DJANGO_ACCOUNT_ACTIVATION_DAYS=3
At this point
docker-compose command can be run
|note| Notes about installing Docker in Debian Stretch:
$ sudo apt update $ sudo apt install -y apt-transport-https ca-certificates wget software-properties-common $ wget https://download.docker.com/linux/debian/gpg $ sudo apt-key add gpg $ echo "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee -a /etc/apt/sources.list.d/docker.list $ sudo apt update $ sudo apt install -y docker-ce docker-compose
$ docker-compose up
This command downloads required Docker images, run and compose
them. Gunicorn logs (see lines
:file:`docker-compose.yml`) are redirected to the terminal.
|tip| Docker compose command can require Administrator rights
sudo). To avoid that add current user to
usermod -aG docker <my-user-name>
By default, Gisquick platform is accessible on localhost port 443 (see
|note| When using self-signed SSL certificates an exception in web browser will be probably required to be added.
At first, running instance should be stopped.
$ docker-compose down
Docker images will be updated by
$ docker-compose pull
And up-to-date container can be afterwards combined as described above.
$ docker-compose up
Access running Docker containers
Example of accessing Bash on
export DJANGO_CONTAINER_ID=`docker ps -qf "ancestor=gisquick/django"` docker exec -it $DJANGO_CONTAINER_ID bash
Run Gisquick over HTTP
- mount volume with custom Gisquick template (line
- change port forwaring (line
After restarting Gisquick instance, the application will be accessible on http://localhost:8000.