An image to be used for the first stage of Django projects that use PostGIS and Debian.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

6.7 KiB


An image to be used for the first stage of Django projects that use PostGIS and Debian.

Table of contents


This repository contains a dockerfile and a compose file used to install some basic system dependencies for Django, PostgreSQL and PostGIS.


You have various options here. The only requirement is that you use PostgreSQL with the PostGIS extension enabled.

These are the tested images:

Image name Full image name Repository docker-debian-postgis-django versions
kartoza/postgis kartoza/postgis:12.1 0.0.1, 0.0.2
postgis/postgis postgis/postgis:12-3.0-alpine 0.0.1, 0.0.2
postgis/postgis postgis/postgis:13-3.1 >= 0.0.4

Import in another project


Build the image directly

  1. clone this repository

  2. run:

    cp Dockerfile.dist Dockerfile
    docker-compose build  --build-arg GID=$(id -g) --build-arg UID=$(id -u) --build-arg PYPI_MIRROR=
  3. add this to the docker compose file of your project:

            image: docker_debian_postgis_django
        # The main service of you project.
                - dependencies
                - ...

Build via git

  1. add this to the docker compose file of your project, where ${VERSION} may correspond to a git tag such as 0.0.3:

            image: docker_debian_postgis_django
                dockerfile: Dockerfile.dist
        # The main service of you project.
                - dependencies
                - ...


Add this line as the first instruction in the Dockerfile:

FROM docker_debian_postgis_django as builder

Add this as the the last COPY instruction in the Dockerfile:

COPY --from=docker_debian_postgis_django /code/utils /code/utils

Continuous integration

Jenkins is used for continuous integration.

Have a look at the implementation in django-futils for an example to get reproducible build for development and production environments.

Warning: some files are automatically replaced when you run the Jenkins pipeline, such as Make sure to run the pipeline in a separate environment.

Other files

  • Makefile.dist: use all setup operations without typing them manually
  • uwsgi.ini.dist: run uwsgi

You can put these files in your repository and rename them into Makefile and uwsgi.ini. django-futils, for example, uses this method.


To be able to call make you must create a .env file in the project root with some variables. See for example the ones used in django-futils.



These dependencies are installed with the RUN command so there is no need to install them manually.

Software Dependency name Purpose
gettext gettext translations
Graphviz graphviz database schema graph
Graphviz libgraphviz-dev database schema graph
Postgis postgis postgres extension
PostgreSQL postgresql-client poll database availability with psql

Version pinning

Version pinning should improve reproducibility. Since version 0.0.3 the Dockerfile in this project uses pinned Debian packages.

If you have a Debian installation you can run # apt-get update && apt policy ${package_name} to find out the current software versions of the dependencies.


Copyright (C) 2020-2021 Franco Masotti (franco \D\o\T masotti {-A-T-} tutanota \D\o\T com)

docker-debian-postgis-django is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

docker-debian-postgis-django is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with docker-debian-postgis-django. If not, see

Changelog and trusted source

You can check the authenticity of new releases using my public key.

Changelogs, instructions, sources and keys can be found at

Crypto donations

  • Bitcoin: bc1qnkflazapw3hjupawj0lm39dh9xt88s7zal5mwu
  • Monero: 84KHWDTd9hbPyGwikk33Qp5GW7o7zRwPb8kJ6u93zs4sNMpDSnM5ZTWVnUp2cudRYNT6rNqctnMQ9NbUewbj7MzCBUcrQEY
  • Dogecoin: DMB5h2GhHiTNW7EcmDnqkYpKs6Da2wK3zP
  • Vertcoin: vtc1qd8n3jvkd2vwrr6cpejkd9wavp4ld6xfu9hkhh0