Prerequisites
- Docker installed and running
- Access to a MariaDB instance
- Access to an MQTT broker
- Network connectivity between containers and external services
Build the Docker image
Build the image
Build the Docker image from the project root:The Dockerfile uses Python 3.12-slim as the base image and installs all dependencies from
requirements.txt:Run the container
Environment variables
Configure the gateway using these environment variables:| Variable | Required | Default | Description |
|---|---|---|---|
DB_HOST | Yes | - | MariaDB host address |
DB_PORT | No | 3306 | MariaDB port |
DB_NAME | Yes | - | Database name |
DB_USER | Yes | - | Database user |
DB_PASSWORD | Yes | - | Database password |
LOG_DIR | No | ./log | Directory for log files |
HTTP_TIMEOUT_SECONDS | No | 10 | HTTP request timeout for POST_ENDPOINT flows |
MQTT_CLIENT_ID | No | mqtt-gateway | MQTT client identifier |
MQTT_KEEPALIVE | No | 60 | MQTT keepalive interval in seconds |
FLOWS_RELOAD_INTERVAL_SECONDS | No | 600 | Interval to reload flows (10 minutes) |
Volume mounts
The container requires one volume mount for persistent logs:./log directory to /app/log inside the container, ensuring logs persist after the container stops.
Network configuration
Ensure the Docker container can reach both the MariaDB database and MQTT broker. If running on a custom Docker network, use the
--network flag.Connect to existing network
Run in background
Run the container as a daemon using the-d flag:
--restart unless-stopped policy ensures the container restarts automatically if it crashes.
View logs
View container logs using Docker commands:./log/YYYY-MM-DD.log.
Stop the container
--rm, the container is automatically removed when stopped. Otherwise, remove it manually: