Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docker/pubsub/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM geopython/pygeoapi:latest

RUN /venv/bin/python3 -m pip install -r /pygeoapi/requirements-pubsub.txt

COPY pygeoapi.config.yml /pygeoapi/local.config.yml
15 changes: 15 additions & 0 deletions docker/pubsub/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# OGC API - Pub/Sub with pygeoapi

This directory contains the necessary components to deploy an MQTT broker and a pygeoapi
instance with OGC API - Pub/Sub enabled.

This example is set up to have communication between the following containers:

- *Mosquitto*: MQTT Broker that publishes notifications.
- *pygeoapi*: Publishes MQTT notifications through the docker network to the broker

To run:

```bash
docker compose up -d --build
```
17 changes: 17 additions & 0 deletions docker/pubsub/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
services:
mqtt:
image: eclipse-mosquitto:2.0
container_name: mosquitto
ports:
- "1883:1883"
- "8884:8884"
volumes:
- ./mosquitto.conf:/mosquitto/config/mosquitto.conf

pygeoapi:
build:
context: .
ports:
- "5000:80"
depends_on:
- mqtt
16 changes: 16 additions & 0 deletions docker/pubsub/mosquitto.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
persistence true
persistence_location /mosquitto/data/
log_dest file /mosquitto/log/mosquitto.log
log_dest stdout
log_timestamp_format %Y-%m-%dT%H:%M:%S

## MQTT Listener
listener 1883
protocol mqtt

## WebSockets Listener
listener 8884
protocol websockets

# Allow anonymous connections
allow_anonymous true
157 changes: 157 additions & 0 deletions docker/pubsub/pygeoapi.config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
# =================================================================
#
# Authors: Tom Kralidis <tomkralidis@gmail.com>
#
# Copyright (c) 2025 Tom Kralidis
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following
# conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#
# =================================================================

server:
bind:
host: 0.0.0.0
port: 5000
url: http://localhost:5000
mimetype: application/json; charset=UTF-8
encoding: utf-8
gzip: false
languages:
# First language is the default language
- en-US
- fr-CA
# cors: true
pretty_print: true
limits:
default_items: 20
max_items: 50
# templates:
# path: /path/to/Jinja2/templates
# static: /path/to/static/folder # css/js/img
map:
url: https://tile.openstreetmap.org/{z}/{x}/{y}.png
attribution: '&copy; <a href="https://openstreetmap.org/copyright">OpenStreetMap contributors</a>'
# manager:
# name: TinyDB
# connection: /tmp/pygeoapi-process-manager.db
# output_dir: /tmp/
# ogc_schemas_location: /opt/schemas.opengis.net
admin: false # enable admin api


pubsub:
name: MQTT
broker:
type: mqtt
url: mqtt://host.docker.internal:1883
channel: my/service/topic

logging:
level: ERROR
#logfile: /tmp/pygeoapi.log

metadata:
identification:
title:
en: pygeoapi default instance
fr: instance par défaut de pygeoapi
description:
en: pygeoapi provides an API to geospatial data
fr: pygeoapi fournit une API aux données géospatiales
keywords:
en:
- geospatial
- data
- api
fr:
- géospatiale
- données
- api
keywords_type: theme
terms_of_service: https://creativecommons.org/licenses/by/4.0/
url: https://example.org
license:
name: CC-BY 4.0 license
url: https://creativecommons.org/licenses/by/4.0/
provider:
name: Organization Name
url: https://pygeoapi.io
contact:
name: Lastname, Firstname
position: Position Title
address: Mailing Address
city: City
stateorprovince: Administrative Area
postalcode: Zip or Postal Code
country: Country
phone: +xx-xxx-xxx-xxxx
fax: +xx-xxx-xxx-xxxx
email: you@example.org
url: Contact URL
hours: Mo-Fr 08:00-17:00
instructions: During hours of service. Off on weekends.
role: pointOfContact

resources:
canada-metadata:
type: collection
title:
en: Open Canada sample data
fr: Exemple de donn\u00e9es Canada Ouvert
description:
en: Sample metadata records from open.canada.ca
fr: Exemples d'enregistrements de m\u00e9tadonn\u00e9es sur ouvert.canada.ca
keywords:
en:
- canada
- open data
fr:
- canada
- donn\u00e9es ouvertes
links:
- type: text/html
rel: canonical
title: information
href: https://open.canada.ca/en/open-data
hreflang: en-CA
- type: text/html
rel: alternate
title: informations
href: https://ouvert.canada.ca/fr/donnees-ouvertes
hreflang: fr-CA
extents:
spatial:
bbox: [-180,-90,180,90]
crs: http://www.opengis.net/def/crs/OGC/1.3/CRS84
providers:
- type: record
name: TinyDBCatalogue
data: tests/data/open.canada.ca/sample-records.tinydb
id_field: externalId
time_field: created
title_field: title
editable: true

hello-world:
type: process
processor:
name: HelloWorld