API Reference#
This section provides detailed information about the ispawn Python API.
Config#
- class ispawn.domain.config.BaseMode(value)[source]#
Bases:
str
,Enum
Base class for mode enums with common string conversion functionality.
- class ispawn.domain.config.CertMode(value)[source]#
Bases:
BaseMode
Available certificate modes for remote proxy.
- LETSENCRYPT = 'letsencrypt'#
- PROVIDED = 'provided'#
- class ispawn.domain.config.Config(install_mode: str, mode: str, domain: str, subnet: str, name: str, dns: List[str] = None, user_in_namespace: bool = False, cert_mode: str | None = None, cert_dir: str | None = None, email: str | None = None, volumes: str = None, mount_point: str = None, env_chunk_path: str | None = None, dockerfile_chunk_path: str | None = None, entrypoint_chunk_path: str | None = None, home_prefix: str = '/home/', timezone: str = 'Europe/Paris')[source]#
Bases:
object
Configuration for reverse proxy and SSL certificates.
- Attrs:
install_mode: Installation mode system or user mode: Proxy mode (local or remote) domain: Domain name for services subnet: Docker network subnet name: Base name network_name: Network name cert_mode: Certificate mode (required for remote proxy) cert_dir: Directory for SSL certificates email: Email for Let’s Encrypt (required if cert_mode is letsencrypt) env_chunk_path: Path to environment file for Docker builds dockerfile_chunk_path: Path to dockerfile chunk for Docker builds entrypoint_chunk_path: Path to entrypoint chunk for Docker builds
- property base_log_dir: str#
Get base log directory path.
- property config_dir: str#
Get config dir
- property config_path: str#
Get config path
- property container_name_prefix: str#
Get container name prefix
- property domain_prefix: str#
Get domain prefix
- static get_system_dir() str [source]#
Get system-wide installation directory.
- Returns:
Path to system-wide installation directory (/etc/ispawn)
- property image_name_prefix: str#
Get image name prefix
- property is_local: bool#
Check if using local proxy mode.
- property is_system_install: bool#
Check if using system-wide installation.
- classmethod load(user_mode=False) Config [source]#
Create Config from system configuration using from_yaml.
- property network_name: str#
Get Docker network name.
- property requires_email: bool#
Check if email is required for certificate configuration.
- property user_root_dir: str#
Get user root directory path.
Image#
- class ispawn.domain.image.ImageConfig(config: Config, base: str, services: List[str])[source]#
Bases:
object
Configuration for building a Docker image with comprehensive settings.
- Attributes:
base (str): Base Docker image to build from services (List[str]): List of services to include in the image config (Config): Configuration object containing build settings
- property dockerfile_template_path: Path#
Get path to the Dockerfile template.
- Returns:
Path: Path to Dockerfile template
- property entrypoint_template_path: Path#
Get path to the entrypoint script template.
- Returns:
Path: Path to entrypoint script template
- get_build_context() Dict[str, Any] [source]#
Get the complete build context for the image.
- Returns:
- Dict[str, Any]: Complete build context including all necessary
files and arguments
- get_template_context(template_type: str) Dict[str, Any] [source]#
Get template context for specified template type.
- Args:
template_type: Type of template (‘Dockerfile’ or ‘entrypoint.sh’)
- Returns:
Dict[str, Any]: Template context variables
- property target_image: str#
Get the target image name.
- Returns:
str: Target image name with prefix and tag
- class ispawn.domain.image.Service(value)#
Bases:
Enum
- JUPYTER = 'jupyter'#
- JUPYTERHUB = 'jupyterhub'#
- JUPYTERLAB = 'jupyterlab'#
- RSTUDIO = 'rstudio'#
- VSCODE = 'vscode'#
- property port: int | None#
Get the port number defined in the service’s config.
- property volumes: Dict[str, str]#
Get the volume mappings defined in the service’s config.
- Returns:
- Dict[str, str]: Dictionary mapping host directory names to container
paths
Container#
- class ispawn.domain.container.ContainerConfig(name: str, config: Config, image_config: ImageConfig, volumes: List[List[str]], group: str | None = None, user: str | None = None, sudo: bool = True)[source]#
Bases:
object
Configuration for a container with comprehensive settings.
- Attributes:
name (str): Original container name group (str): Required group for RStudio access (defaults to username)
Services#
Image Service#
- class ispawn.services.image.ImageService(config: Config)[source]#
Bases:
object
Service for handling Docker image operations.
- build_image(config: ImageConfig) Image [source]#
Build a Docker image using the provided configuration.
- Args:
config: ImageConfig instance with build configuration
- Returns:
Built Docker image
- Raises:
ImageError: If image build fails
- check_image(config: ImageConfig) bool [source]#
Check if a Docker image exists based on the provided configuration.
Container Service#
- class ispawn.services.container.ContainerService(config: Config)[source]#
Bases:
object
Service for handling Docker operations.
- list_containers(running: bool = None) List[Dict[str, str]] [source]#
List all ispawn containers.
- Args:
- running (bool, optional):
If True, only running containers are returned. If False, only stopped containers are returned. Defaults to None (all containers).
- Returns:
List[Dict[str, str]]: List of container information
- Raises:
ContainerError: If container listing fails
- run_container(config: ContainerConfig, force: bool = False) Container [source]#
Run a Docker container with the specified configuration.
- Args:
container: Container configuration force: Whether to force replace an existing container
- Returns:
Running Docker container
- Raises:
ContainerError: If container operations fail
Config Manager#
Configuration manager for ispawn.
- class ispawn.services.config.ConfigManager(config: Config, force: bool = False)[source]#
Bases:
object
Configuration manager for ispawn.