The MobiData BW Integrationsplattform (IPL) is an API platform aggregating various kinds of mobility data for Baden-Württemberg.
- By converting and harmonizing several underlying data sources, and then integrating them with each other, it spares consumers having to spent time on each city or region, allowing them to focus on their project.
- By providing individual APIs specifically tailored towards certain forms of mobility (e.g. sharing vehicles), it allows consumers to query & filter the data more easily.
Using Docker Compose, this repo ties together and configures ("orchestrates") all of IPL's components, hence the name ipl-orchestration.
Most of these components are third-party projects, re-used in order to provide industry-standard APIs and to make long-term maintenance easier; Check the Compose Services section for more details.
Important
ipl-orchestration is intended to be deployed via Ansible, using the playbooks defined in ipl-ansible, but it should also be usable "standalone". The following steps explain how to set it up manually.
First, we have to install the Docker Engine (Community Edition), its command-line interface (CLI) and Docker Compose; Developers usually install Docker Desktop and get them out-of-the-box; Follow Docker's official installation instructions.
Docker installation instructions for Debian/Ubuntu
[!WARNING]
These instructions may become outdated, please check the official Docker documentation.
Because we want to use the latest Docker packages, we set up the official package sources by Docker Inc. instead of using the built-in system sources.
# configure the Docker Inc. package sources
curl -fsSL 'https://download.docker.com/linux/ubuntu/gpg' | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
chmod a+r /etc/apt/keyrings/docker.gpg
echo "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# update the list of available packages
apt update
# install Docker (Desktop)
apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-pluginIn addition, you need the following tools:
Now that we have installed the prerequisites, let's clone the ipl-orchestration repository (repo); It defines all Compose services that make up IPL.
To mimic the Ansible deployment, we clone into /srv/docker-unmanaged/ipl.
# Clone the Git repository.
mkdir -p /srv/docker-unmanaged/ipl
cd /srv/docker-unmanaged/ipl
git clone https://github.com/mobidata-bw/ipl-orchestration.git .Note
Most IPL services will run as-is with their default configuration specified in the .env file.
However, some services need customization to your local installation using an additional .env.local file that partially overrides .env and that is not checked into Git version control.
# create .env.local file from .env.local.example template
cp .env.local.example .env.local
# adapt .env.local now to your environment- You should configure (properly generated) random passwords for all components that need one (e.g. the PostgreSQL DBs) instead of using the default ones!
- You must enter valid credentials to various third-party APIs (e.g.
$LAMASSU_TIER_USER) for the respective services to work. - You may want to adapt variables like
$*_BASE_URLto your setup.
Make sure you have access to the Docker images hosted in the mobidata-bw orginization's GitHub Container Registry (a.k.a. ghcr.io) by pulling them.
Note
Because running Docker Compose with both .env & .env.local is tedious, the Makefile defines shortcuts for common docker compose commands, make docker-pull in this case.
docker compose --env-file .env --env-file .env.local pull
# or use a convenient shortcut for the command above:
make docker-pullYour installation should now be ready!
Refer to the Controlling Docker Compose Services section for details on how to start the IPL services.
Because IPL is basically a set of Docker Compose services, it is also operated this way.
Important
The following code snippets assume that you have either defined all config values necessary for your local installation in .env.local (recommended, check the installation instructions), or exported them as environment variables.
There is a Makefile which defines shortcuts for useful Compose commands; It assumes that you're using .env.local. The equivalent shortcut is shown beneath each “manual” docker compose command.
If you want to start all services and keep them running in your current shell (in the foreground), use docker compose up:
docker compose --env-file .env --env-file .env.local up
# or use the shortcut:
make docker-upInstead, you can also start an individual service (and the services it depends on), or multiple individual services:
docker compose --env-file .env --env-file .env.local up lamassu redis
# or use the shortcut:
make docker-up SERVICE="lamassu redis"Note
It often makes sense to start all services of one "domain" together because often they rely on each other. For example, if you want to work with the ParkAPI API (park-api-flask), we recommend starting all ParkAPI services (park-api-flask, park-api-worker, etc.).
If you want to run all services in a detached mode (a.k.a. as daemons), use the --detatch/-d option. This way, you can close you shell session, and they will keep running.
docker compose --env-file .env --env-file .env.local up --detach
# or use the shortcut:
make docker-up-detachedOf course, you can also run individual services in detached mode:
docker compose --env-file .env --enf-file .env.local up --detach redis
# or use the shortcut:
make docker-up-detached SERVICE="redis"You can pull the latest Docker images (for each service from its respective registry):
docker compose --env-file .env --env-file .env.local pull
# or use the shortcut:
make docker-pullAs with docker compose up (see above), you can also pull individual services’ images:
docker compose --env-file .env --env-file .env.local pull redis
# or use the shortcut:
make docker-pull SERVICE="redis"To re-run all services with these newly pulled images, use docker compose down & docker compose up (optionally with --detached). Again, if you don’t explicitly specify services, it will restart all:
docker compose --env-file .env --env-file .env.local down
docker compose --env-file .env --env-file .env.local up --detached
# or use the shortcuts:
make docker-down
make docker-up-detachedWarning
docker compose restart does not take changes to .env or .env.local into account! It merely restarts the services' containers with the environment variables as when they were originally started. To restart all services with modified/new environment variables, use down & up, as illustrated above. This should be your default workflow instead.
docker-compose.yml is the core of ipl-orchestration; It defines, configures and connects Compose services.
Most important and/or opinionated (read: MobiData-BW-specific) configuration parameters are abstracted into Compose variables which are defined in .env and .env.local.
The subdirectories mimic the a typical Unix filesystem structure:
etccontains config files with whatever configuration is not passed into services as environment variables. These config files are mounted into the respective containers.bincontains some helper commands used to manage the running system, e.g. for reloading the configuration of a service. Most of them are mounted into the respective containers.varmostly contains data that services create during runtime: downloaded/stored data, various logs files, lockfiles, etc. Most ofvaris Git-ignored; A notable exception isvar/www, which contains static datasets served by thecaddyservice (see below).
ipl-orchestration uses Docker's bridge networking. We also make most services accessible to the outside world through our ingress/reverse proxy service (see ingress below).
This means that each Compose service that exposes a port has
- a port on the container's IP address (container port);
- a port on the host's IP address (host port);
- an HTTP path on the ingress (ingress path), if configured.
The following table lists all IPL components and their respective Docker Compose services.
| component & functionality | Compose service | permanently running? | host port | public HTTP path | notes |
|---|---|---|---|---|---|
| HTTP ingress/reverse proxy (Traefik Proxy) | ingress |
✔︎ | 8080 | n/a | exposes all other services via HTTP |
| HTTP ingress/reverse proxy: admin UI | ingress |
✔︎ | 8081 | - | allows inspecting Traefik's operating state |
| GeoServer | geoserver |
✔︎ | 8600 | /geoserver |
serves geospatial data sources via WMS, WFS, WMTS, etc. |
| OCPDB: API | ocpdb-flask |
✔︎ | 7000 | /ocpdb |
aggregates charge point data sources |
| OCPDB: background worker | ocpdb-worker |
✔︎ | - | - | fetches & imports 3rd-party data |
| OCPDB: initialization script | ocpdb-init |
- | n/a | runs once on startup | |
| OCPDB: database (PostgreSQL) | ocpdb-db |
✔︎ | - | n/a | |
| OCPDB: Regionalschlüssel importer | ocpdb-regionalschluessel-importer |
- | n/a | runs once on startup; imports administrative region boundaries (VG25 GeoPackage) into the OCPDB database for Regionalschlüssel assignment | |
| ParkApi: API | park-api-flask |
✔︎ | 7500 | /park-api |
aggregates parking lot data sources |
| ParkAPI: background worker | park-api-worker |
✔︎ | - | - | fetches & imports 3rd-party data |
| ParkAPI: database initialization script | park-api-init-db |
- | n/a | runs once on startup | |
| ParkAPI: converter initialization script | park-api-init-converter |
- | n/a | runs once on startup | |
| ParkAPI: database (PostgreSQL) | park-api-db |
✔︎ | - | n/a | |
| ParkAPI: heartbeat | park-api-heartbeat |
✔︎ | - | - | |
| ParkAPI: Regionalschlüssel importer | park-api-regionalschluessel-importer |
- | n/a | runs once on startup; imports administrative region boundaries (VG25 GeoPackage) into the ParkAPI database for Regionalschlüssel assignment | |
| GBFS: Lamassu | lamassu |
✔︎ | 8500 | /sharing/gbfshttp://10.70.172.11:3000/assets |
aggregates (public) GBFS vehicle sharing data sources |
| GBFS: Lamassu (admin UI) | lamassu |
✔︎ | 9002 | - | allows inspecting Lamassu's operating state |
| GBFS: Lamassu database (Redis) | redis |
✔︎ | - | n/a | |
| GBFS: x2gbfs | x2gbfs |
✔︎ | - | - | generates GBFS feeds from proprietary ride-sharing APIs |
| GBFS: database (PostgreSQL) | ipl-db |
✔︎ | 5432 | n/a | stores fetched GBFS data, served by geoserver |
| Dagster: task runner | dagster-pipeline |
✔︎ | - | - | runs (custom Python) tasks (e.g. GTFS import, webcam images download) & collects their logs |
| Dagster: task scheduler | dagster-daemon |
✔︎ | - | - | orchestrates DAGs of tasks |
| Dagster: UI | dagster-dagit |
✔︎ | 3000 | - | shows logs & results of the scripts |
| Dagster: database (PostgreSQL) | dagster-postgresql |
✔︎ | - | n/a | |
| IPL Proxy | transformer-proxy |
✔︎ | 8400 | - | on-the-fly patching of HTTP resources from 3rd parties; used by OCPDB, x2gbfs, etc. |
| RadVIS: database (PostgreSQL) | ipl-db |
✔︎ | 5432 | n/a | stores RadVIS data, served by geoserver |
| GTFS: API (PostgREST) | gtfs-api |
✔︎ | 4000 | /gtfs |
serves GTFS data in gtfs-db as an API |
| GTFS: documentation (Stoplight Elements) | gtfs-api-docs |
✔︎ | 4001 | /docs/gtfs |
UI documenting the GTFS API |
GTFS: importer (postgis-gtfs-importer) |
gtfs-importer |
- | - | downloads, cleans & imports GTFS into the database; started by a Dagster task | |
| GTFS: database (PostgreSQL) | gtfs-db |
✔︎ | - | n/a | stores imported GTFS data, served by gtfs-api and geoserver |
| database proxy (pgbouncer) | pgbouncer |
✔︎ | 6432 | n/a | proxies services' connections to databases (dagster-postgresql, gtfs-db, etc.) |
| task/message queue (RabbitMQ) | rabbitmq |
✔︎ | - | - | |
| web server (Caddy): static data | caddy |
✔︎ | 6999 | /datasets |
serves static datasets |
| web server (Caddy): webcam images | caddy |
✔︎ | 6999 | /webcams |
webcam images pulled by dagster-pipeline |
| web server (Caddy): OCPDB images | caddy |
✔︎ | 6999 | /ocpdb/images |
serves OCPDB images |
| web server (Caddy): private GBFS feeds | caddy |
✔︎ | 6999 | /gbfs |
serves private GBFS feeds generated by x2gbfs |
| web server (Caddy): meta files | caddy |
✔︎ | 6999 | /.well-known, /robots.txt, /favicon.ico |
serves miscellaneous files (not datasets) |
| web server (Caddy): requests statistics | caddy |
✔︎ | 6998 | - | serves reports generated by goaccess |
| SFTP server | sftp |
✔︎ | 10022 | - | lets the police upload traffic incidents |
| computation of request statistics (GoAccess) | goaccess |
- | - | generates reports from the Traefik (ingress) requests log; started manually/externally |
To run IPL reliably, we recommend monitoring
- the host machine (e.g. using the node exporter)
- IPL's services in general (e.g. using the blackbox exporter)
- the Docker daemon
In addition, some of IPL's services also expose domain-specific metrics:
| Compose service | host port | which metrics |
|---|---|---|
ingress |
8081 | HTTP requests count/rate/duration/status codes, Go runtime |
lamassu |
9002 | GBFS errors/sync status, HTTP requests, JVM runtime |
ocpdb-flask |
7000 | sources status/errors |
gtfs-api |
4002 | date/time of GTFS import, DB connection stats, PostgREST internals |
park-api-flask |
7500 | sources status/errors |