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 (
Official Gisquick Docker containers are available from Docker Hub.
Docker images can be put together using
command. The command reads configuration file in YAML
language. Sample configuration of Gisquick services is shown below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
version: "2" services: qgisserver: restart: always image: gisquick/qgis-server volumes: - ./_data/publish:/publish/:ro ports: - "9000:90" django: restart: always image: gisquick/django links: - qgisserver volumes: - ./_data/data/:/var/www/gisquick/data/ - ./_data/media/:/var/www/qisquick/media/ - ./_data/publish:/publish/ environment: - GUNICORN_WORKERS=2 - GUNICORN_ERRORLOG=- - GUNICORN_ACCESSLOG=- logging: driver: json-file options: max-size: "10m" max-file: "10" nginx: restart: unless-stopped image: gisquick/nginx links: - django volumes_from: - django:ro volumes: - ./_data/etc/letsencrypt/:/etc/letsencrypt/ - ./_data/var/www/certbot/:/var/www/certbot/ ports: - "443:443" environment: - NGINX_HOST=server logging: driver: json-file options: max-size: "10m" max-file: "10"
Sample configuration is also available from Gisquick source code: docker/example.docker-compose.yml.
It is important to set up shared directories mounted by Docker containers
as volumes. QGIS Server requires setting up
directory which is used for published Gisquick projects (see line
7). Django Application stores SQLite database in
17), tile cache is managed in
18). SSL certificates used by Nginx Web Server
are stored in directory
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
$ mkdir -p _data/publish _data/media _data/data _data/etc/letsencrypt/live
Directory for SSL certificates is defined by
environmental variable (see line
43) located in
directory. For sample configuration, the SSL certificates will be
directory. See example of creating self-signed certificate below.
$ mkdir -p _data/etc/letsencrypt/live/localhost $ openssl req -x509 -nodes -days 3650 -newkey rsa:2048 \ -keyout _data/etc/letsencrypt/live/localhost/privkey.pem \ -out _data/etc/letsencrypt/live/localhost/fullchain.pem \ -subj "/C=CZ/ST=Prague/L=Prague/O=Gisquick/OU=IT Department/CN=localhost"
For production self-signed SSL certificates will be not enough. In this case can be recommended Certbot (LetsEncrypt) certificates. See additional information on GitHub.
There are more environmental variables which can be defined. Django container allows to set up:
DJANGO_GISQUICK_UPLOAD_MAX_SIZE- max. size of uploaded projects (string)
False(bool) to enable/disable debug messages
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
$ 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
docker-compose.yml) are redirected to the terminal.
usermod -aG docker <my-user-name>
By default, Gisquick platform is accessible on localhost port 443 (see
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¶
into directory where
docker-compose.yml lives. Change NGINX service
configuration in order to:
- mount volume with custom Gisquick template (line
- change port forwaring (line
After restarting Gisquick instance, the application will be accessible on http://localhost:8000.