Docker Deployment

Deploy RouteMQ using Docker containers for consistent, scalable environments.

Quick Start

Basic Docker Deployment

# Clone the repository
git clone <your-repo-url>
cd RouteMQ

# Build the Docker image
docker build -t routemq:latest .

# Run with default settings
docker run -d \
  --name routemq \
  -e MQTT_BROKER=test.mosquitto.org \
  -e MQTT_PORT=1883 \
  -p 8080:8080 \
  routemq:latest

Use the included docker-compose.yml for a complete stack:

Dockerfile Explanation

The RouteMQ Dockerfile uses a multi-stage approach optimized for production:

Key Features

  • Python 3.12: Latest stable Python version

  • UV Package Manager: Fast dependency resolution and installation

  • Non-root User: Security best practice

  • Optimized Layers: Minimal image size with dependency caching

  • Health Checks: Built-in application health verification

Docker Compose Configuration

Complete Stack

Environment Configuration

Environment Variables

Create a .env file for configuration:

Docker Environment File

Supporting Configuration Files

Mosquitto Configuration

Create docker/mosquitto/mosquitto.conf:

Mosquitto Password File

Create docker/mosquitto/passwd:

MySQL Initialization

Create docker/mysql/init/01-init.sql:

Redis Configuration

Create docker/redis/redis.conf:

Development vs Production

Development Setup

Production Setup

Multi-Stage Dockerfile

For optimized production builds:

Container Commands

Build Commands

Run Commands

Management Commands

Troubleshooting

Common Issues

Container Won't Start

Database Connection Issues

Memory Issues

Health Checks

Security Considerations

Container Security

Network Security

Secrets Management

Performance Optimization

Resource Limits

Volume Optimization

Next Steps

Last updated