An image to be used for the first stage of Django projects that use PostGIS and Debian. https://software.franco.net.eu.org/frnmst/docker-debian-postgis-django
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.
 
 
 
Franco Masotti 62b4ce3a79
Removed example.
2 months ago
utils Updated email. 2 months ago
.allowed_licenses.yml Added hook. 2 months ago
.gitignore Fixed instruction. 9 months ago
.pre-commit-config.yaml Updated email. 2 months ago
Dockerfile Updated base images and pinned packages to Debian 11. 2 months ago
LICENSE First commit. 11 months ago
Makefile Updated email. 2 months ago
Makefile.dist Removed useless variable. 2 months ago
Pipfile Updated dependency. 2 months ago
README.md Removed example. 2 months ago
docker-compose.yml Updated email. 2 months ago
uwsgi.ini.dist Added two variables. 3 months ago

README.md

docker-debian-postgis-django

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

Table of contents

Description

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

Database

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 https://github.com/kartoza/docker-postgis 0.0.1, 0.0.2
postgis/postgis postgis/postgis:12-3.0-alpine https://github.com/postgis/docker-postgis 0.0.1, 0.0.2
postgis/postgis postgis/postgis:13-3.1 https://github.com/postgis/docker-postgis >= 0.0.4

Import in another project

Build

Build the image directly

  1. clone this repository
  2. run docker-compose build --build-arg GID=$(id -g) --build-arg UID=$(id -u)
  3. add this to the docker compose file of your project:
services:
    dependencies:
        image: docker_debian_postgis_django

    # The main service of you project.
    main:

        ...

        depends_on:
            - 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:
services:

    dependencies:
        image: docker_debian_postgis_django
        build:
            context: https://software.franco.net.eu.org/frnmst/docker-debian-postgis-django.git#${VERSION}

    # The main service of you project.
    main:

        ...

        depends_on:
            - dependencies
            - ...

Note: adding the usual dockerfile: Dockerfile key under build leads to this error:

unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /tmp/docker-build-git352150547/https:: no such file or directory
ERROR: Service 'dependencies' failed to build

Dockerfile

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 SECRET_SETTINGS.py. Make sure to run the pipeline in a separate environment.

Other files

Makefile.dist and uwsgi.ini.dist are used respectively to:

  • use all setup operations without typing them manually
  • 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.

Variables

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.

Dependencies

Dockerfile

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.

License

Copyright (C) 2020-2021 frnmst (Franco Masotti) franco.masotti@tutanota.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 http://www.gnu.org/licenses/.

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 blog.franco.net.eu.org/software.

Crypto donations

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