Docker Deployment
Relevant source files
The following files were used as context for generating this wiki page:
Horizon utilizes a containerized architecture to ensure consistent development and production environments. The deployment strategy focuses on high availability and ease of setup, primarily leveraging Docker Compose for local orchestration and planned Kubernetes manifests for production scale. The system is designed as a three-tier architecture consisting of a presentation layer, a business logic layer (API server), and a data persistence layer.
Sources: README.md:43-52, IMPLEMENTATION_PLAN.md:48-51, IMPLEMENTATION_PLAN.md:129-131
Infrastructure Overview
The Docker deployment environment provides the necessary backing services for the Horizon CMDB, specifically PostgreSQL for primary data storage and Redis for caching and session management.
Component Architecture
The following diagram illustrates the relationship between the Docker-managed services and the Horizon application components.
The architecture ensures that internal services communicate over an isolated bridge network while exposing specific ports for external access.
Sources: docker-compose.yml:8-63, IMPLEMENTATION_PLAN.md:53-56
Core Services Configuration
PostgreSQL Database
Horizon uses PostgreSQL 18-alpine as its primary relational store. The configuration includes performance tuning and health checks to ensure database readiness before application startup.
| Configuration Item | Default Value | Description |
|---|---|---|
| Image | postgres:18-alpine | Alpine-based PostgreSQL image |
| Port | 5432 | Exposed database port |
| Memory Limit | 512M | Hard memory limit for the container |
| Shared Buffers | 128MB | Memory allocated for caching data |
| Max Connections | 100 | Maximum concurrent database connections |
Sources: docker-compose.yml:8-44, scripts/docker-dev.sh:111-120
Redis Cache
Redis 8-alpine handles session management and caching. It is configured with an LRU (Least Recently Used) eviction policy to manage memory effectively within a 256MB limit.
| Configuration Item | Default Value | Description |
|---|---|---|
| Image | redis:8-alpine | Alpine-based Redis image |
| Port | 6379 | Exposed Redis port |
| Max Memory | 256mb | Memory ceiling for Redis data |
| Policy | allkeys-lru | Eviction strategy when memory limit is reached |
Sources: docker-compose.yml:47-63
Lifecycle and Orchestration
Automated Setup Script
The scripts/docker-dev.sh script manages the lifecycle of the Docker environment. It performs requirement checks, directory initialization, and service health monitoring.
Sources: scripts/docker-dev.sh:1-137
Volume Persistence
Data persistence is achieved through named local volumes mapped to the .docker/volumes directory in the project root. This ensures that database records and cache data survive container restarts and upgrades.
- Postgres Data:
${PWD}/.docker/volumes/postgres - Redis Data:
${PWD}/.docker/volumes/redis
Sources: docker-compose.yml:66-78, scripts/docker-dev.sh:64-73
Networking and Security
The deployment utilizes a dedicated internal network for service communication, preventing unauthorized external access to the database and cache layers.
| Network Feature | Value | Purpose |
|---|---|---|
| Driver | bridge | Standard Docker bridge networking |
| Internal Name | horizon-internal | Isolated communication channel |
| Subnet | 172.28.0.0/16 | Static IP range for internal routing |
| Gateway | 172.28.0.1 | Network gateway address |
Sources: docker-compose.yml:81-87
Development Workflow
To start the containerized environment, developers use the CLI or the provided management script:
- Start Services:
./scripts/docker-dev.sh start - Verify Status:
docker-compose ps - Application Connection: The API server connects using a connection string built from environment variables (e.g.,
HORIZON_DATABASE_HOST,HORIZON_DATABASE_PORT).
Sources: scripts/docker-dev.sh:84-110, crates/cli/src/main.rs:50-58
Conclusion
The Docker deployment strategy for Horizon provides a robust, reproducible foundation for both development and production. By encapsulating complex dependencies like PostgreSQL 18 and Redis 8 within Docker, the project minimizes "works on my machine" issues and provides a clear path toward Kubernetes-based orchestration for larger IT infrastructures.