This repository contains scripts and recipes for deploy of the G3W-SUITE web-gis application with Docker and Docker compose .

Server sizing

CPU, memory and storage needs depend on the number of users, the complexity of the maps, the data and the enabled services. This guide does not prescribe a universal minimum: test the deployment with representative projects and concurrent users before choosing production capacity.

Monitor container CPU and memory usage with docker stats. Check free space on the shared volume with df -h <shared-volume-path>; allow room for the database, project data, uploads, tile cache and backups.

For a cloud deployment, choose a Linux host that supports the required Docker images and Docker Compose. Use persistent storage, plan backups and provide a domain and HTTPS for public access.

Deploy

Use docker-compose.yml for a standard installation of G3W-SUITE 3.11.

Clone the stable Docker branch and enter its directory:

git clone --branch v3.11.x https://github.com/g3w-suite/g3w-suite-docker.git
cd g3w-suite-docker

Configuration

Create a file .env (or copy .env.example and rename it in .env) and place it in the main directory, the file will contain the database credentials (change <your password>) and other settings:

# External hostname, for docker internal network aliases
WEBGIS_PUBLIC_HOSTNAME=demo.g3wsuite.it

# This volume is persistent and mounted by all
# containers as /shared-volume
WEBGIS_DOCKER_SHARED_VOLUME=./shared-volume

# Super User account
G3WSUITE_ADMIN_USERNAME=admin
G3WSUITE_ADMIN_PASSWORD=<your_password>

# DB setup
G3WSUITE_POSTGRES_USER_LOCAL=g3wsuite
G3WSUITE_POSTGRES_PASS=<your_password>
G3WSUITE_POSTGRES_DBNAME=g3wsuite
G3WSUITE_POSTGRES_HOST=postgis
G3WSUITE_POSTGRES_PORT=5432

PGSERVICEFILE=/pg_service/pg_service.conf

Description of other environment variables that can be used, are available on Docker environment variables

Run

Before the first start, check services.g3w-suite.environment in docker-compose.yml. If it lists G3WSUITE_ADMIN_PASS, replace that entry with G3WSUITE_ADMIN_PASSWORD so the setup script receives the password from .env.

docker compose up -d

Open http://localhost:8080. If the site does not respond, check the service status and the startup logs:

docker compose ps -a
docker compose logs --tail=100 g3w-suite postgis

Login Page

Optional Huey worker

Use the alternative docker-compose-consumer.yml only if you need the Huey worker for background jobs. It defines a complete stack, not an override. If you choose it, pass -f docker-compose-consumer.yml to subsequent Compose commands as well.

docker compose -f docker-compose-consumer.yml up -d

Builds

Docker compose will download images from docker hub (https://hub.docker.com/u/g3wsuite), but is also possible build main image of G3W-SUITE and other docker-compose images.

G3W-SUITE

The main suite docker image can be built with:

docker build --build-arg G3W_SUITE_BRANCH=v.3.11.x -f Dockerfile.g3wsuite.dockerfile -t g3wsuite/g3w-suite:local-v3.11 .

The build argument selects the stable admin branch. Without it, the setup script clones dev, even when using the stable Docker checkout. The Dockerfile uses the g3wsuite/g3w-suite-deps-ltr:v3.11.x base image.

To run a locally built image, change the image tag for g3w-suite and, if you use the optional worker, for g3w-suite-consumer as well.

Postgis

The stable Compose files use kartoza/postgis:16-3.4.

Setups

PG_SERVICE

To use of PostgreSql Service, put your service setups into ./secrets/pg_service.conf, the conf file will be mounted into docker container at runtime to PGSERVICEFILE path position.

HTTPS additional setup

For HTTPS, configure the hostname in .env and config/nginx/nginx.conf, including the administrator email in the latter. Ensure the domain resolves to the server and HTTP port 80 reaches the Nginx port 8080 for the ACME challenge; the provided Compose file publishes 8080, not 80.

With the HTTP configuration running, obtain a certificate before switching the includes in config/nginx/nginx.conf from django to django_ssl and restarting the selected stack. The repository's run_certbot.sh invokes an interactive container and recreates the default Compose stack, not the consumer stack; adapt and test certificate issuance and renewal for your deployment rather than assuming it works unattended in cron.

Volumes

Data, projects, uploads and the database are stored in a shared mounted volume shared-volume, the volume should be on a persistent storage device and a backup policy must be enforced.

The stable .env.example uses ./shared-volume. Set WEBGIS_DOCKER_SHARED_VOLUME in .env to a persistent location suitable for production.

First time setup

Set a strong administrator password in .env before starting a new installation. The .env.example file contains example credentials that must be changed.

Sign in to the administration panel with G3WSUITE_ADMIN_USERNAME and G3WSUITE_ADMIN_PASSWORD. Setup runs only once per shared volume and sets passwords on existing users as well; use a fresh database and volume for a new installation. After initialization, change passwords in the administration interface, not by editing .env.

Caching

Tile cache can be configured and cleared per-layer through the webgis admin panel and lasts forever until it is disabled or cleared.

Tip: enable cache on linestring and polygon layers.

Editing

Editing module is active by default, to avoid simultaneous feature editing by two or more users, the editing module works with a feature lock system. Without the Huey worker, schedule lock cleanup on the host. The command removes locks older than four hours by default. With Huey enabled, the editing module already schedules this cleanup periodically.

0 * * * * cd /path/to/g3w-suite-docker && docker compose exec -T g3w-suite python3 /code/g3w-admin/manage.py check_features_locked

Front-end App

Set the environment variable

FRONTEND=True

This will set the front end app as the default app

Style customization

Templates can now be overridden by placing the overrides in the config/g3w-suite/overrides/templates, a Docker service restart is required to make the changes effective.

The logo is also overridden (through config/g3w-suite/settings_docker.py which is mounted as a volume), changes to the settings file require the Docker service to be restarted.

A custom CSS is added to the pages, the file is located in config/g3w-suite/overrides/static/style.css and can be modified directly, changes are effective immediately.

Performances optimization

General rules (in no particular order: they are all mandatory):

  1. set scale-dependent visibility for the entire layer or for some filtered features (example: show only major roads until at scale 1:1E+6)
  2. when using rule-based/categorized classification or scale-dependent visibility create indexes on the column(s) involved in the rule expression (example: "create index idx_elec_penwell_ious on elec_penwell_ious (owner);" )
  3. start the project with only a few layers turned on by default
  4. do not turn on by default base-layers XYZ such as (Google base maps)
  5. do not use rule-based/categorized rendering on layers with too many categories (example: elec_penwell_public_power), they are unreadable anyway
  6. enable redering simplification for not-point layers, set it to Distance 1.2 and check Enable provider simplification if available

PostgreSQL administration

PostgreSQL runs in a Docker container. From the Docker checkout, connect as the configured database user:

docker compose exec postgis sh -c 'psql -U "$POSTGRES_USER" -d "${POSTGRES_DBNAME%%,*}"'

Database backups

With the standard stack running and GNU Make installed, run the stable Docker checkout's backup target from its root:

make db-backup ENV=prod ID=before-upgrade

The script attempts to dump G3WSUITE_POSTGRES_DBNAME, data_production and data_testing to backup/<ID>/ under WEBGIS_DOCKER_SHARED_VOLUME. Check the output for errors and verify that each expected .bck file was created before relying on the backup.

These are database dumps, not a full installation backup. Also back up projects, file-based data, uploads, mounted configuration and any databases not covered by the script. Keep a copy off the server. The db-restore target replaces databases: test recovery on a separate installation before using it on live data.

Portainer usage

Portainer (https://www.portainer.io) is a docker-based web application used to edit and manage Docker applications in a simple and intuitive way.

See Add a new stack for how to deploy the standard Compose file with Portainer.

Contributors