Skip to content

feat(sdk): start sandbox from Dockerfile via Image.from_dockerfile#1043

Open
Issac-Newton wants to merge 2 commits into
alibaba:masterfrom
Issac-Newton:feature/start-from-dockerfile
Open

feat(sdk): start sandbox from Dockerfile via Image.from_dockerfile#1043
Issac-Newton wants to merge 2 commits into
alibaba:masterfrom
Issac-Newton:feature/start-from-dockerfile

Conversation

@Issac-Newton

@Issac-Newton Issac-Newton commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator

fixes #531

Summary

Image.from_dockerfile(path) lets users declare a sandbox image from a local
Dockerfile or build context. Sandbox.start() transparently builds + pushes
inside a DinD builder sandbox and starts the user sandbox from the resulting
tag — no manual docker build / docker push needed.

Design

  • 4-segment image name: {registry_url}/{namespace}/{repository}:{content_hash},
    where content_hash is the full SHA-256 of the build context (OCI digest length).
    Content changes → new tag → deterministic cache.
  • Two-layer cache check to handle SDK ↔ builder network asymmetry (common
    with internal/VPC registries):
    • L1 SDK-side HTTP HEAD — fast path, skips builder on hit.
    • L2 docker manifest inspect inside builder — catches hits L1 missed
      due to network reachability.
  • path accepts both a directory (build context, must contain Dockerfile)
    and a single Dockerfile file (only that file is the context).
  • Builder image env handled separately: rock-env-builder ships with
    daemon.json that puts dockerd data-root on the XFS volume ROCK already
    bind-mounts at /data/logs, disables containerd-snapshotter so BuildKit
    sidesteps overlay-on-overlay, and is built clean of stale pidfiles. SDK is
    unaware.
  • Zero admin/db change: Image resolves to a string at the SDK boundary
    before the HTTP call.

Docs

Test plan

  • pytest tests/unit/sdk/sandbox/test_image.py
  • pytest tests/integration/sdk/sandbox/test_image_build.py -m need_admin
  • Fast suite green
  • Manually verified on vpc-zb-a with the actual rock-env-builder image

Co-Authored-By: Claude Opus 4.7 [email protected]

@Issac-Newton
Issac-Newton force-pushed the feature/start-from-dockerfile branch 8 times, most recently from e7515e1 to a80b39b Compare June 3, 2026 06:55
def from_dockerfile(
path: str | Path,
*,
registry: ImageRegistry | None = None,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

registry,builder_config如果不填,默认值怎么获取

)
return status == 200

async def build_with_builder(self, spec: BuildSpec, builder: Sandbox) -> str:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

私有

self._builder_config = builder_config
self._builder = builder

def create_builder(self) -> Sandbox:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

私有

@Issac-Newton
Issac-Newton force-pushed the feature/start-from-dockerfile branch 5 times, most recently from 343623a to a82bb59 Compare June 12, 2026 12:09
Issac-Newton and others added 2 commits June 12, 2026 20:12
Add AcrConfig (registry + builder_image) dataclasses, GET /acr_config
API returning temporary ACR credentials via GetAuthorizationToken, and
aliyun-python-sdk-cr as an explicit admin dependency.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Add Image.from_dockerfile() API for building sandbox images from local
Dockerfiles, with ImageBuilder, ImageRegistry, and BuilderConfig models.
Includes user guide docs (en + zh-Hans) and SDK-side /acr_config
integration.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@Issac-Newton
Issac-Newton force-pushed the feature/start-from-dockerfile branch from a82bb59 to ca74efd Compare June 12, 2026 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Start Sandbox From Dockerfile

2 participants