OpenFactory Deployment Strategies#
OpenFactory Assets are deployed on the OpenFactory cluster using one of the deployment strategy classes listed below.
These classes inherit from the abstract base class openfactory.openfactory_deploy_strategy.OpenFactoryServiceDeploymentStrategy.
Currently, two deployment strategies are implemented:
openfactory.openfactory_deploy_strategy.LocalDockerDeploymentStrategyIntended for development purposes when no OpenFactory cluster is available. This strategy deploys all OpenFactory services as standalone Docker containers on the local machine.
openfactory.openfactory_deploy_strategy.SwarmDeploymentStrategyThis is the default deployment strategy used in OpenFactory. It deploys services as Docker Swarm services, suitable for production or multi-node environments.
- class openfactory.openfactory_deploy_strategy.OpenFactoryServiceDeploymentStrategy[source]#
Bases:
ABCAbstract base class for OpenFactory service deployment strategies.
- abstractmethod deploy(*, image, name, env, labels=None, command=None, ports=None, networks=None, constraints=None, resources=None, mode=None, mounts=None)[source]#
Deploy a service using the specified parameters.
- Return type:
- Parameters:
image (str) – Docker image to deploy.
name (str) – Name of the service or container.
env (List[str]) – Environment variables in KEY=VALUE format.
labels (Optional[Dict[str, str]]) – Metadata labels (Swarm only).
command (Optional[str]) – Command to override the default entrypoint.
ports (Optional[Dict[int, int]]) – Port mappings from host to container (host:container).
networks (Optional[List[str]]) – Networks to connect the service or container to.
constraints (Optional[List[str]]) – Constraints for placement (Swarm only).
resources (Optional[Dict[str, Any]]) – Resource limits and reservations.
mode (Optional[Dict[str, Any]]) – Service mode (Swarm only).
mounts (Optional[List[dict]]) – List of Docker mount specifications.
- class openfactory.openfactory_deploy_strategy.LocalDockerDeploymentStrategy[source]#
Bases:
OpenFactoryServiceDeploymentStrategyDeployment strategy for local Docker containers (non-Swarm).
- deploy(*, image, name, env, labels=None, command=None, ports=None, networks=None, constraints=None, resources=None, mode=None, mounts=None)[source]#
Run a local Docker container.
See parent method for argument descriptions.
- Return type:
Note
Only the first network in the list is used.
constraints and mode are ignored for local containers.
- remove(service_name)[source]#
Remove a Docker container.
- Parameters:
service_name (str) – Docker container to be removed.
- Raises:
docker.errors.NotFound – If the container does not exist.
docker.errors.APIError – If removal fails due to a Docker API issue.
- swarm_mount_to_container_mount(mount_dict)[source]#
Convert a Docker Swarm-style mount dictionary to a local Docker Mount object.
- Return type:
Mount- Parameters:
mount_dict (dict) – Mount dictionary in Swarm format, as returned by
openfactory.filelayer.nfs_backend.NFSBackend.get_mount_spec().- Returns:
docker.types.Mount – A Mount object suitable for use with docker.containers.run().
Note
Supports
volumemounts only;bindmounts should be handled separately.The returned Mount preserves the target path, source name, read-only flag, and driver configuration specified in the input dictionary.
NFS-specific options (e.g.,
nfsvers=4) are already included in the mount dictionary byget_mount_spec().
- class openfactory.openfactory_deploy_strategy.SwarmDeploymentStrategy[source]#
Bases:
OpenFactoryServiceDeploymentStrategyDeployment strategy for Docker Swarm mode.