Docker Integration
Relevant source files
The following files were used as context for generating this wiki page:
The Docker Integration within the FLEXT Plugin system enables production-ready plugins to interact with containerized services such as PostgreSQL, Redis, and LDAP. It provides standardized patterns for configuring network-dependent plugins, validating connectivity to Docker Compose services, and ensuring that plugin business rules are met before activation in a containerized environment.
This system leverages the FlextPluginPlatform and FlextPluginModels to define entities that represent database connectors, cache handlers, and authentication directories. The integration focuses on service availability checks and robust configuration management to ensure seamless operation within Docker-orchestrated architectures.
Sources: examples/03_docker_integration.py:1-12, src/flext_plugin/_utilities/plugin_platform.py:17-25
Service Connectivity and Validation
A critical component of Docker integration is the pre-execution validation of network services. The system utilizes a socket-based availability check to verify that required Docker services (e.g., database or cache) are reachable at specified hosts and ports before the plugin lifecycle proceeds.
Connectivity Flow
The following diagram illustrates the sequence for validating Docker service availability before plugin initialization.
Plugin Configuration Patterns
Docker-integrated plugins use specific JsonMapping structures to define connection parameters. These configurations are designed to match environment-specific settings typically found in docker-compose.yml files, such as internal network hostnames and standard service ports.
Standardized Service Configurations
| Service Type | Key Parameters | Purpose |
|---|---|---|
| PostgreSQL | host, port, database, ssl_mode, connection_pool | Database connectivity and resource management. |
| Redis | host, port, db, socket_timeout, health_check_interval | Cache connection persistence and monitoring. |
| LDAP | host, port, user_dn, base_dn, pool_size | Directory service authentication and pooling. |
Sources: examples/03_docker_integration.py:36-47, examples/03_docker_integration.py:65-79, examples/03_docker_integration.py:97-108
Configuration Implementation
Example of a production-ready PostgreSQL configuration for a Docker environment:
postgres_config: t.JsonMapping = {
"host": "localhost",
"port": 5432,
"database": "flext_db",
"user": "flext",
"password": "flext_dev_password",
"ssl_mode": "prefer",
"connection_timeout": 10,
"max_connections": 20,
"connection_pool": True,
}
Sources: examples/03_docker_integration.py:38-48
Domain Entity Integration
Plugins intended for Docker environments are instantiated as FlextPluginModels.Plugin.Entity objects. These entities encapsulate metadata such as dependencies (e.g., psycopg2-binary for Postgres or redis for Redis) and plugin types (DATABASE, AUTHENTICATION).
Plugin Architecture
This class diagram shows the relationship between the base Plugin Entity and specialized Docker-compatible instances.
Lifecycle and Execution within Docker
The FlextPluginPlatform manages the lifecycle of Docker plugins. In a containerized context, the platform handles registration, activation, and resource cleanup.
Execution Metrics
The system records execution data to metadata, allowing for monitoring of service performance within Docker.
record_execution(time, success): Updatesexecution_count,total_execution_time, and success/failure counts.record_error(message): Incrementserror_countand stores thelast_errorstring.
Sources: src/flext_plugin/models.py:146-193, src/flext_plugin/_utilities/plugin_platform.py:321-344
Platform Status
The Docker-aware platform provides a platform_status property that summarizes the operational state of all plugins.
| Metric | Description |
|---|---|
total_plugins | Count of all registered plugin entities. |
active_plugins | Count of plugins currently in an ACTIVE status. |
total_executions | Historical count of plugin execution attempts. |
running_executions | Current number of in-flight plugin tasks. |
Sources: src/flext_plugin/_utilities/plugin_platform.py:188-198
Summary
Docker Integration in the FLEXT system provides a robust framework for managing network-dependent plugins. By combining socket-based service discovery with Pydantic-validated domain models, the system ensures that plugins interacting with Dockerized PostgreSQL, Redis, and LDAP services are correctly configured and reachable before they enter an active state.
Sources: examples/03_docker_integration.py:141-164, tests/unit/test_examples.py:46-56