Skip to content

Deploy Docker

Deploy Docker — mvp.deploy_docker

Cluster: Core Infrastructure | Type: component | MCP Tools: None

Overview

Docker container runtime implementation for local and registry-based deployments. Wraps the docker CLI to build images from a Dockerfile, push to any OCI registry, run containers with port mappings and environment variables, and stop running containers — all returning structured DeployResult responses. Supports a dry_run mode for safe pipeline testing without side effects.

Pilot-ready, not full production platform

deploy_docker is suitable for first-user pilots, local CI builds, and simple single-VPS Docker deployments when paired with the actual Web, MCP, or REST base Dockerfiles. It is not by itself proof that the full G6 deployment path is production-ready. Before using it for paid customers, validate the generated image in staging with real Docker, run service-specific startup/readiness checks, confirm environment variables and secrets are configured, and complete the repository-wide dependency lockfile work from the launch plan.

When to use:

  • Building a G6 base Docker image locally during development or CI
  • Running a base container locally with custom port and environment overrides
  • Serving as the default container runtime for the cicd pipeline on developer machines
  • Running a named, restartable container on a simple VPS by setting production_mode=True

Reliability envelope:

  • inspect preserves raw docker inspect output and adds parsed container_state fields for status, health, ports, restart policy, image labels, and redacted environment variable names.
  • Generated Dockerfiles include structured warnings for unpinned base images, missing USER, missing HEALTHCHECK, secret-like ARG/ENV, and privileged exposed ports.
  • Production image pushes always use the scan-before-push floor; scanner unavailability or scan failure returns completion_state: blocked-escalated in the artifact envelope.
  • Known degradation codes include docker_daemon_unavailable, scanner_unavailable, registry_auth_missing, healthcheck_absent, capability_unsupported, and rollback_not_executed.

Example:

from mvp.deploy_docker import DockerBlock, DockerInput
from mvp.deploy_core.schema import ImageSpec

block = DockerBlock(name="docker")
result = block.infer(DockerInput(
    op="build",
    image=ImageSpec(name="g6-rest", tag="dev"),
    context_dir=".",
))
# result.ok → True; result.value.stage → "build"

Works well with: deploy_core, deploy_podman, cicd

Public API

DockerBlock(AIBlock[DockerInput, DeployResult, None])

AIBlock that delegates to DockerRuntime based on input.op.

Field Type Default
name str 'docker'

Methods:

infer(data: DockerInput) -> Result[DeployResult]

DockerRuntime

ContainerRuntime implementation using the docker CLI.

Constructor:

Parameter Type Default
executable str 'docker'
dry_run bool False

Methods:

build(image: ImageSpec, context_dir: str) -> DeployResult

push(image: ImageSpec, registry: str) -> DeployResult

run(image: ImageSpec, ports: dict[int, int], env: dict[str, str], production_mode: bool = False) -> DeployResult

stop(container_id: str) -> DeployResult

stop_by_name(name: str) -> DeployResult

Stop a container by its assigned name.

inspect(name: str) -> DeployResult

DockerInput

Input for DockerBlock.infer() — dispatches to DockerRuntime.

Field Type Default
op DockerOp required
image ImageSpec field(default_factory=lambda: ImageSpec(name=''))
context_dir str '.'
registry str ''
ports dict[int, int] field(default_factory=dict)
env dict[str, str] field(default_factory=dict)
container_id str ''
production_mode bool False
scan_before_push bool False
build_config dict field(default_factory=dict)
dry_run bool True
approval_confirmed bool False