Quick Start
Python Docker Quick Start
For most users, the recommended way to use the AISDB Python package is by installing it with pip. The main purpose of the Python docker images in this repository is to provide a build environment for the Python wheel files that can be used for pip installation, as well as providing a reference and testing environment. The meridiancfi/aisdb:latest image is based on python:slim with the AISDB package wheel installed. In the meridiancfi/aisdb-manylinux:latest image, wheel binary files are compiled from Rust and Python source code using a manylinux base docker image. The aims to provide a convenient way to distribute binary Python extensions as wheels on Linux. To start the container, ensure that docker and docker-compose are installed, and enter into the command line:
The current working directory will be mounted inside the container as a volume. The same can be achieved with docker-compose in the context of the repository compose file:
Compose Services
In addition to the Python AISDB docker image, AISDB provides a complete suite of cloud services for storing, accessing, viewing, and networking AIS data. These services are defined in the docker-compose.yml file in the project repository. Cloud services are implemented in a microservices architecture, using a software-defined network defined in the compose file. Services include:
docserver
NodeJS webserver to display Sphinx documentation (such as this webpage)
To start all AISDB cloud services, navigate to the repository root directory and enter into the command line (root permissions may be required):
Development and Deployment
The following services are used for the development and deployment of AISDB
build-wheels
Build manylinux-compatible wheels for Python package distribution. The resulting wheel file is installed in aisdb-python.
Services running with docker compose will read environment variables from a .env file in the project root directory. An example .env file is included here:
Interacting with Postgres Database
In some cases, Postgres may preferred over SQLite. Postgres offers improved concurrency and scalability over SQLite, at the cost of requiring more disk space and compute resources. The easiest and recommended way to use AISDB with the Postgresql database is via docker (to manually install dependencies, see ). To get started, navigate to the repository root directory, and ensure docker and docker-compose are installed. Start the AIS receiver, database server, and postgres database docker images. Sudo permissions may be required for Docker and docker-compose.
The receiver will fetch live data streaming from the MERIDIAN AIS network, and store it in the postgres database. Start the AIS receiver and Postgres database services from the command line with docker-compose:
The Postgres database may be interfaced using Python in the same manner as the default SQLite database by using as a drop-in replacement for the default that uses SQLite.
The resulting dbconn may then be used similar to how DBConn is used in the
Start the AIS receiver, Postgres database, and database webserver services from the command line using the following command. See for more info on docker services. Alternatively, the services can be run in a local environment instead of a docker environment as described in .
The receiver service will listen for new data from MERIDIAN’s AIS receiver, and store it in the postgres database. The db-server service provides a web API for the AIS data stored in the postgres database. This listens for WebSocket connections on port 9924, and returns JSON-formatted vessel tracks in response to queries. The following Python code provides an example of how to asynchronously query AIS data from db-server. This code can either run in a local Python environment or in the aisdb-python docker image. While this example uses Python, the web API can be accessed using any language or package using the , such as JavaScript, as long as requests are formatted as utf8-encoded JSON.
Interacting with the Map