Skip to content

ci: replace sed/awk Dockerfile rewriting with --build-context overrides#987

Merged
thepagent merged 1 commit into
mainfrom
fix/build-context-smoke-test
Jun 3, 2026
Merged

ci: replace sed/awk Dockerfile rewriting with --build-context overrides#987
thepagent merged 1 commit into
mainfrom
fix/build-context-smoke-test

Conversation

@thepagent
Copy link
Copy Markdown
Collaborator

Summary

Replace the fragile sed/awk-based Dockerfile rewriting in docker-smoke-test.yml with Docker BuildKit --build-context overrides.

What changed

The "Build image (skip Rust compilation)" step now:

  1. Creates .fake-builder/build/target/release/openab with the pre-built binary
  2. Passes --build-context builder=.fake-builder to docker buildx build
  3. Automatically detects additional named Rust stages (e.g. adapter-builder in Dockerfile.antigravity) and overrides them too

Docker BuildKit completely skips the original FROM rust stages when a --build-context override is provided, using our fake directory as the stage context instead.

Before (sed/awk rewriting)

  • awk strips all FROM rust stages from the Dockerfile
  • Stub stages are prepended manually
  • Broke on multi-stage builds (antigravity)
  • Generates temp Dockerfile.ci / Dockerfile.final

After (--build-context)

  • Zero Dockerfile modifications
  • Multi-stage builds work natively
  • BuildKit fully skips Rust stages
  • 19 lines vs 22 lines, simpler logic

Testing

CI will validate this on all 12 Dockerfile variants in the matrix.

Fixes #986

Replace the fragile sed/awk-based Dockerfile rewriting in docker-smoke-test.yml
with Docker BuildKit --build-context overrides.

Instead of parsing and rewriting Dockerfiles at CI time, we now:
1. Create fake builder directories with pre-built binaries at the
   expected paths (build/target/release/<binary>)
2. Pass --build-context builder=.fake-builder to docker buildx build
3. Docker skips the entire Rust build stage and uses our directory instead

This handles multi-stage builds (e.g. Dockerfile.antigravity with
adapter-builder) automatically by detecting all named Rust stages.

Benefits:
- No fragile string manipulation in CI
- Dockerfiles remain unmodified and self-contained
- Multi-stage builds work without special-casing
- BuildKit fully skips Rust stages (faster CI)

Fixes #986
@github-actions github-actions Bot added the closing-soon PR missing Discord Discussion URL — will auto-close in 3 days label Jun 3, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 3, 2026

⚠️ This PR is missing a Discord Discussion URL in the body.

All PRs must reference a prior Discord discussion to ensure community alignment before implementation.

Please edit the PR description to include a link like:

Discord Discussion URL: https://discord.com/channels/...

This PR will be automatically closed in 3 days if the link is not added.

@thepagent thepagent merged commit c159400 into main Jun 3, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

closing-soon PR missing Discord Discussion URL — will auto-close in 3 days

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ci: refactor Dockerfiles to support PREBUILT_BINARY arg for CI optimization

1 participant