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
1
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:2
Verify the image
Confirm the image was built successfully:
Run the container
1
Create log directory
Create a directory on the host to persist logs:
2
Run with environment variables
Run the container with required environment variables:
Environment variables
Configure the gateway using these environment variables: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: