"""Build container images from container state.

This module provides functionality to:
- Generate Dockerfiles from running/stopped containers
- Build OCI images using docker commit or Dockerfile
- Push images to container registries

Example:
    >>> from gaol.build import build_image, generate_dockerfile
    >>>
    >>> # Generate Dockerfile from container
    >>> dockerfile = generate_dockerfile("mycontainer")
    >>> print(dockerfile.render())
    >>>
    >>> # Build image from container
    >>> result = build_image("mycontainer", tag="v1.0")
    >>> print(f"Built: {result.image_id}")
    >>>
    >>> # Push to registry
    >>> push_result = push_image("myapp:v1.0", registry="ghcr.io/user")
"""

from __future__ import annotations

from gaol.build.dockerfile import (
    DockerfileGenerator,
    generate_dockerfile,
)
from gaol.build.exceptions import (
    BaseImageNotFoundError,
    BuildError,
    ContainerNotFoundError,
    ContainerNotRunningError,
    DockerfileGenerationError,
    ImageBuildError,
    ImageNotFoundError,
    ImageTagError,
    PackageDetectionError,
    RegistryAuthenticationError,
    RegistryError,
    RegistryPushError,
    UnsupportedRuntimeError,
)
from gaol.build.image import (
    BUILD_REPO_PREFIX,
    ImageBuilder,
    build_image,
    get_image_history,
    get_image_info,
)
from gaol.build.models import (
    BuildConfig,
    BuildMethod,
    BuildResult,
    DockerfileInstruction,
    GeneratedDockerfile,
    ImageInfo,
    ImageLayer,
    PackageManager,
    PushProgress,
    PushResult,
)
from gaol.build.registry import (
    RegistryClient,
    push_image,
    push_image_with_progress,
)

__all__ = [
    # High-level functions
    "build_image",
    "generate_dockerfile",
    "get_image_info",
    "get_image_history",
    "push_image",
    "push_image_with_progress",
    # Classes
    "DockerfileGenerator",
    "ImageBuilder",
    "RegistryClient",
    # Models
    "BuildConfig",
    "BuildMethod",
    "BuildResult",
    "DockerfileInstruction",
    "GeneratedDockerfile",
    "ImageInfo",
    "ImageLayer",
    "PackageManager",
    "PushProgress",
    "PushResult",
    # Exceptions
    "BaseImageNotFoundError",
    "BuildError",
    "ContainerNotFoundError",
    "ContainerNotRunningError",
    "DockerfileGenerationError",
    "ImageBuildError",
    "ImageNotFoundError",
    "ImageTagError",
    "PackageDetectionError",
    "RegistryAuthenticationError",
    "RegistryError",
    "RegistryPushError",
    "UnsupportedRuntimeError",
    # Constants
    "BUILD_REPO_PREFIX",
]
