Overview
Docker Compose provides a complete local development environment with all services: API, TimescaleDB, PostgreSQL, Redis, and EMQX MQTT broker.This deployment is ideal for local development and testing. For production deployments, use Kubernetes.
Architecture
Thedocker-compose.yaml defines a complete stack:
Prerequisites
- Docker Desktop or Docker Engine v20.10+
- Docker Compose v2.0+
- At least 4GB RAM allocated to Docker
- Ports available: 8080, 5432, 5433, 6379, 1883, 8883, 8083, 8084, 18083
Quick Start
Configure environment variables
Copy the example file and generate secure passwords:Edit
.env and replace placeholders with secure passwords:Service Configuration
TimescaleDB (Time-Series Database)
View Configuration
View Configuration
iotKey Tables:sensor_readings- Hypertable with 7-day chunks, 2-year retention
PostgreSQL (Metadata Database)
View Configuration
View Configuration
metadataKey Tables:tenants- Multi-tenant isolationgreenhouses- Greenhouse configurationssensors,actuators- Device registryusers- User managementalerts- Alert history
Redis (Cache)
View Configuration
View Configuration
greenhouse:messagesTTL: 24 hours (renewed on each write)Access:EMQX (MQTT Broker)
View Configuration
View Configuration
GREENHOUSE/{tenantId}- Multi-tenant sensor dataGREENHOUSE- Legacy topic (maps to DEFAULT tenant)GREENHOUSE/RESPONSE- Echo for verification
EMQX_DASHBOARD_USERNAME/PASSWORD)Test Connection:API (Spring Boot)
View Configuration
View Configuration
- API: http://localhost:8080
- Swagger UI: http://localhost:8080/swagger-ui.html
- Health: http://localhost:8080/actuator/health
- OpenAPI Docs: http://localhost:8080/v3/api-docs
Environment Variables
Volumes and Persistence
All data is persisted in named Docker volumes:Backup Volumes
Restore Volumes
Common Operations
Start Services
View Logs
Stop Services
Restart Service
Check Status
Troubleshooting
API fails to start: 'Connection refused' to database
API fails to start: 'Connection refused' to database
Cause: API starts before databases are ready.Solution: Check Verify database health:Look for
depends_on with health checks:(healthy) status. If unhealthy:Port already in use: '5432'
Port already in use: '5432'
Cause: Another PostgreSQL instance is running on port 5432.Solution 1: Stop conflicting service:Solution 2: Change port in
docker-compose.yaml:EMQX dashboard shows 'Connection refused'
EMQX dashboard shows 'Connection refused'
Cause: EMQX container not fully started.Solution: Wait for EMQX to initialize (can take 30-60 seconds):Wait for:Then access: http://localhost:18083
Redis authentication failed
Redis authentication failed
Cause: Test connection:Expected:
REDIS_PASSWORD not set or incorrect.Solution: Verify password in .env:PONGOut of disk space
Out of disk space
Cause: Docker volumes consuming too much space.Solution: Clean up old data:
Next Steps
Configuration
Configure environment variables, database connections, and application settings
Kubernetes Deployment
Deploy to production using Kubernetes with high availability
API Reference
Explore REST endpoints and WebSocket connections
MQTT Integration
Connect IoT devices via MQTT protocol