justb4 / docker-mapproxy-mapserver-mapnik

MapProxy Docker Image extended with MapServer and Mapnik for backends
ISC License
3 stars 0 forks source link

MapProxy for Docker with MapServer and Mapnik support

GitHub license GitHub release Docker Pulls

This image extends the "justb4" Docker Image for MapProxy with MapServer with Mapnik binaries. Reason is that MapProxy supports not only directly calling the MapServer executable mapserv, i.s.o. of accessing MapServer via OGC WMS but also supports Mapnik backend. You can also use this image as a regular Mapnik Docker Image without running MapProxy. It contains for example the Mapnik Python bindings, as MapProxy uses.

Image Tags and Versions

Convention: <mapproxy-version>-<mapserver-version>-<mapnik-version>-<buildnr>, for example

Patches

For optimal performance, patches are applied to mapnik.py. See patches/README.

How to setup

The setup is similar as in the "justb4" Docker Image for MapProxy README. Only some extra config is needed for Mapnik. Below an example for a docker-compose file.

version: "3"

services:

  mapproxy:

    image: justb4/mapproxy-mapserver-mapnik:latest

    container_name: mapproxy

    environment:
      - MAPPROXY_PROCESSES=4
      - MAPPROXY_THREADS=2
      - UWSGI_EXTRA_OPTIONS=--disable-logging --max-worker-lifetime 30
      - DEBUG=0

    ports:
      - "8086:8080"

    volumes:
      - ./config/mapproxy:/mapproxy
      - ./my-mapnik-dir:/mapnik
      - /var/mapproxy_cache:/mapproxy_cache

In your MapProxy config YAML you can refer to the Mapnik backend binary. In the sources: section where you would normally configure backend WMS-es:

sources:
.
.

  my_mapnik_source:
    type: mapnik
    mapfile: /mapnik/my-mapnik-file.xml
    # seed_only: true
    coverage:
      bbox: [ -20000.0,275000.0,300000.0,650000.0 ]
      srs: 'EPSG:28992'

The Mapproxy Documention shows some alternative config options.

Running Mapnik Directly

Create a mapnik.sh script like:

#!/bin/bash
#
# usage: mapnik.sh "your commandline"
#

export WORK_DIR=/opt/mapproxy
docker run --rm -v "$(pwd):${WORK_DIR}" -w ${WORK_DIR} -it justb4/mapproxy-mapserver-mapnik:latest sh -c "${@}"

And then call it like mapnik.sh generate-tiles.py, like this example.