Skip to content

docs: add a derived-image recipe for plugins - #355

Merged
uniqueg merged 8 commits into
devfrom
docs/323-plugin-image
Oct 31, 2026
Merged

uniqueg merged 8 commits into
devfrom
docs/323-plugin-image

Conversation

@uniqueg

@uniqueg uniqueg commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

Summary

Adds the derived-image recipe for plugins (sub-issue of #194):

  • New docs page Plugin images (docs/plugin-images.md, nav after "Plugins"). It covers the following steps:
    1. Pick the release image by digest.
    2. Pin the plugins with examples/plugin-image/resolve.sh. The script runs pip inside the image, with the image's packages as constraints, and writes plugins.txt with versions and wheel hashes.
    3. Download the wheels and verify them (gh attestation verify, link to the verification docs of foca-plugins).
    4. Build with examples/plugin-image/Dockerfile. It installs only the hash-pinned wheels of the build context (--no-index --no-deps --require-hashes), then runs pip check. Its Dockerfile.dockerignore sends only plugins.txt and wheels/, so .env* never reach the build.
    5. Scan and sign the image.
    6. Deploy with the chart (protes.image together with plugins).
    7. The page also covers local builds.
  • PLUGINS build argument in the root Dockerfile for local builds only. It is empty by default, so published images only gain a no-op step. It is not hash-pinned, pip check runs after the install, and Docker Compose passes the host's PLUGINS through.
  • Chart README and values: the plugin example now sets the derived image together with the plugins, and the README links to the recipe. docs/plugins.md links to the recipe too, and its foca-plugins link now points to the foca-plugins docs site instead of GitHub.
  • CI: the smoke job gets a new step, "Check plugin image" (tests/smoke/plugins.sh). It runs these checks with a test plugin distribution (tests/smoke/plugin/, plugin smoke.tag, which tags new tasks):
    • It builds the plugin's wheel and pins it with resolve.sh from a local directory. The pin must match the wheel's hash.
    • It checks that a wrong hash fails the build with pip's hash error.
    • It builds the derived image from protes:local.
    • It restarts proTES and the worker with the plugin enabled and pinned (tests/smoke/plugins.yaml, tests/smoke/plugins.config.yaml).
    • It checks that a new task carries the plugin's tag.
  • tests/test_config_examples.py now also validates the plugin examples of the new page and of the new smoke overlay.

proTES stays on FOCA 0.18, so no FOCA 0.19 features (plugin store) are documented. The page says that foca-plugins has not published any plugins yet.

Closes #323

Verification

  • pre-commit run --all-files passed.

  • mkdocs build --strict passed. The Dockerfile snippet and {{ version }} render.

  • coverage run -m pytest (mongomock) passed: 1042 passed, 169 skipped (Helm is not installed locally, so the chart tests were skipped), 100% coverage.

  • Local Docker, on an isolated Compose project with its own image names and port:

    • tests/smoke/check.sh passed.
    • tests/smoke/plugins.sh passed.
    • The base image refuses to start with the plugin config (Plugin 'smoke.tag' is not installed).
  • The operator commands of the page, run against a locally built proTES image with real PyPI packages (humanize, requests-toolbelt):

    • Resolving lists only the missing packages, and a conflict (pydantic<2) fails without writing plugins.txt.
    • Download, build and pip check work, the image runs as user 1000, and a wrong hash fails the build.
    • With no base image given, the build fails with a clear error.
  • PLUGINS build argument: verified by hand by building with and without it.

  • The chart README example validates against values.schema.json (checked with jsonschema).

  • CI on the PR: all checks passed, including the "Check plugin image" step of the smoke test ("Plugin smoke test passed") and the Read the Docs preview.

Review

Not light lane: the PR changes the Dockerfile, CI and test scripts, so it got the full review in two rounds. All medium findings were fixed: resolving against the image's packages as constraints, failed resolution no longer leaving an empty plugins.txt, the resolve step tested in CI, the link to the chart README's Configuration section, and a negative hash test. The cheap low findings were fixed too.

Declined review findings

  • Recipe on its own page instead of a section of docs/plugins.md: requested by the maintainer's brief, to keep edits to shared files minimal. docs/plugins.md links the page.
  • pip-compile/uv and pypi-attestations verify as named in the issue: the recipe resolves with pip's dry-run report inside the image instead, so the result fits the image's Python, platform and installed packages without extra tools. The page says why. I could not verify the exact pypi-attestations CLI syntax here, so the page shows gh attestation verify (as foca-plugins documents it) and links foca-plugins' verification docs for PEP 740.
  • Shared token helper for check.sh and plugins.sh: left as is. The duplication is a few lines, and leaving check.sh untouched avoids conflicts with the parallel provenance work.
  • CI test for the PLUGINS build argument: it installs from the package index, so it was verified by hand only. The page documents its limits: specifiers without spaces, no credentials.
  • setuptools>=83 in the test plugin: kept, as in foca-plugins (CVE fix).
  • Fewer configuration options in plugins.sh: kept. The image names and PYTHON let the script run next to other local stacks.
  • Sourcery: build from the same image ID in the smoke test: declined. The steps run one after the other in CI, and a mixed-up base image would fail the run, not pass it.
  • Sourcery: name a real foca-plugins release: declined. Nothing is published yet, and the page says so. Sourcery's stale-pins finding was fixed (6bf99fb).

Open questions

None.

🤖 Generated with Claude Code

uniqueg and others added 7 commits October 31, 2026 15:00
Install plugins in local builds of the image from the package index,
with their dependencies (`--build-arg PLUGINS="<requirements>"`), then
run `pip check`. Empty by default, so the published images are
unchanged; Docker Compose passes the host's `PLUGINS`. Not pinned by
hash: deployments use the derived-image recipe instead.

Refs #323

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Add the Dockerfile of the derived-image recipe for plugins
(`examples/plugin-image/`): it installs the hash-pinned wheels of its
build context only (`--no-index --no-deps --require-hashes`), then runs
`pip check`; its `Dockerfile.dockerignore` sends `plugins.txt` and
`wheels/` only. The smoke test (`tests/smoke/plugins.sh`, a CI step of
`smoke`) builds it from the app's image with a test plugin
(`tests/smoke/plugin/`), restarts the app with the plugin enabled and
checks that new tasks get the plugin's tag.

Refs #323

Co-Authored-By: Claude Opus 5.5 <[email protected]>
New page "Plugin images": choose the release image by digest, resolve
the plugins against it (pip's dry-run report, with hashes), download
and verify the wheels, build with `examples/plugin-image/`, scan and
sign, deploy with the chart's values, and local builds with `PLUGINS`.
The plugins page and the chart's README link it; the chart's example
sets the derived image together with the plugins. The docs and the
smoke test's config overlay are validated with the other plugin
examples, and Development describes the smoke test.

Closes #323

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Address review findings: resolve `plugins.in` with the image's packages
as constraints, so that plugins needing other versions of them fail at
once instead of silently changing them; note empty `plugins.txt`, that
`PLUGINS` takes specifiers without spaces and never credentials, and
the chart's image value in the plugins page and `values.yaml`. The
smoke test also checks that a wrong hash fails the build.

Refs #323

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Move the resolve step of the recipe into `examples/plugin-image/
resolve.sh`, which writes `plugins.txt` only if pip resolved the
plugins (a failed resolution left an empty file before, which the
docs read as "nothing to build"). The smoke test pins the test plugin
with it, from the wheel's directory, compares the pin with the wheel's
hash, and requires the wrong-hash build to fail with pip's hash error.
The example Dockerfile skips the build check of its base image
argument, which has no default on purpose.

Refs #323

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sourcery-ai

sourcery-ai Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

This PR adds a documented, reproducible derived-image recipe that resolves plugins against a pinned proTES release, verifies and hash-pins wheel artifacts, builds offline with dependency checks, and integrates deployment guidance, local-development support, and comprehensive CI smoke coverage.

Sequence diagram for plugin image resolution and build

sequenceDiagram
    participant Operator
    participant Resolve as resolve.sh
    participant Image as proTES release image
    participant Docker as Docker build
    participant Pip as pip

    Operator->>Resolve: resolve.sh PROTES_IMAGE plugins.in plugins.txt
    Resolve->>Image: pip list --format freeze
    Image-->>Resolve: Installed package constraints
    Resolve->>Image: pip install --dry-run --report --constraint
    Image-->>Resolve: Resolved distributions and wheel hashes
    Resolve-->>Operator: Write plugins.txt
    Operator->>Docker: Build with PROTES_IMAGE, plugins.txt, wheels/
    Docker->>Pip: pip install --no-index --no-deps --require-hashes
    Pip-->>Docker: Install pinned local wheels
    Docker->>Pip: pip check
    Pip-->>Docker: Dependency validation
Loading

Flow diagram for the reproducible plugin image recipe

flowchart LR
    A["Pinned proTES release image"] --> B["resolve.sh\nResolve plugins with image constraints"]
    B --> C["plugins.txt\nVersions and wheel hashes"]
    C --> D["pip download\nDownload hash-verified wheels"]
    D --> E["gh attestation verify\nVerify wheel provenance"]
    E --> F["Derived Docker image\nOffline install and pip check"]
    F --> G["Scan and sign image"]
    G --> H["Deploy with Helm\nprotes.image and plugins"]
Loading

File-Level Changes

Change Details Files
Documents a reproducible, digest-based workflow for building and deploying proTES images with verified, hash-pinned plugin wheels.
  • Adds the Plugin images page covering base-image selection, environment-aware resolution, wheel verification, offline hash-enforced builds, scanning/signing, deployment, local builds, and CI testing.
  • Adds a derived-image Dockerfile that installs only context-provided wheels with --no-index, --no-deps, and --require-hashes, then runs pip check.
  • Adds resolve.sh to run pip dry-run resolution inside the base image, constrain against installed packages, and emit exact versions and wheel hashes.
  • Restricts the derived-image build context to plugins.txt and wheels/.
docs/plugin-images.md
examples/plugin-image/Dockerfile
examples/plugin-image/Dockerfile.dockerignore
examples/plugin-image/resolve.sh
Adds an explicitly development-only plugin installation path to the standard image and Compose workflow.
  • Adds an empty-by-default PLUGINS Docker build argument that installs unpinned requirements from the package index and runs pip check.
  • Passes the host PLUGINS environment variable through Docker Compose and documents its security and reproducibility limitations.
Dockerfile
docker-compose.yaml
docs/development.md
Updates plugin deployment documentation and chart examples to use the derived image alongside enabled plugin configuration.
  • Adds the derived image and digest-based deployment settings to the chart README example and links to the recipe.
  • Updates chart comments and plugin documentation to reference protes.image and the new recipe.
  • Moves the foca-plugins reference to its documentation site.
deployment/README.md
deployment/values.yaml
docs/plugins.md
mkdocs.yml
Adds an end-to-end CI smoke test for plugin resolution, integrity enforcement, image construction, startup, and runtime behavior.
  • Builds a local test plugin wheel, resolves it against the base image, verifies the generated hash, and asserts that a tampered hash fails the build.
  • Builds and runs the derived image with the plugin enabled, then verifies that submitted tasks receive the plugin-generated tag.
  • Adds the test plugin distribution, Compose overlay, plugin configuration, and CI workflow step.
.github/workflows/ci.yml
tests/smoke/plugins.sh
tests/smoke/plugins.yaml
tests/smoke/plugins.config.yaml
tests/smoke/plugin/pyproject.toml
tests/smoke/plugin/smoke_plugin.py
Extends configuration-example validation to cover the new plugin recipe and smoke-test overlay.
  • Collects plugin examples from the new documentation and plugin smoke configuration.
  • Requires those sources in the plugin example coverage assertion.
tests/test_config_examples.py

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@read-the-docs-community

read-the-docs-community Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Documentation build overview

📚 proTES | 🛠️ Build #35546874 | 📁 Comparing 6bf99fb against latest (4244881)

  🔍 Preview build  

4 files changed
+ plugin-images/index.html
± deployment/index.html
± development/index.html
± plugins/index.html

@codecov

codecov Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (4244881) to head (6bf99fb).

Additional details and impacted files
@@            Coverage Diff            @@
##               dev      #355   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           23        23           
  Lines         2209      2209           
=========================================
  Hits          2209      2209           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@uniqueg
uniqueg marked this pull request as ready for review October 31, 2026 15:35

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 3 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="examples/plugin-image/resolve.sh" line_range="28" />
<code_context>
+  < "${requirements}")"
+pins="$(jq -r '.install[] | "\(.metadata.name)==\(.metadata.version) --hash=sha256:\(.download_info.archive_info.hashes.sha256)"' \
+  <<< "${report}")"
+printf '%s\n' "${pins}" | sed '/^$/d' > "${output}"
</code_context>
<issue_to_address>
**Old plugin pins survive failed resolution**

When a previous resolution wrote the output and a later resolution fails, `resolve.sh` exits before writing `output`, leaving the earlier `plugins.txt` in place, so callers that continue build with the old plugin set instead of the requested one.

Remove or truncate `output` before starting resolution so a failed run cannot leave stale pins.
</issue_to_address>

### Comment 2
<location path="tests/smoke/plugins.sh" line_range="22" />
<code_context>
+context="$(mktemp -d)"
+trap 'rm -rf "${context}"' EXIT
+
+base="${PROTES_IMAGE:-protes:local}"
+# The build context of the recipe: the wheel, and `plugins.txt`, which
+# `resolve.sh` pins against the base image, from the wheel's directory
</code_context>
<issue_to_address>
**Concurrent rebuild changes plugin base**

When another Compose build retags `protes:local` after resolution but before the derived-image build, the resolver reads the image currently tagged `protes:local`, but the later `docker build` resolves that tag again; a concurrent Compose rebuild can retag it between those steps, so the derived image is built on a different package set than the one used to pin the plugin, making the smoke result flaky or invalid.

Resolve and build from the same immutable image ID or digest, capturing it before resolution and using it for both operations.

Also at `tests/smoke/plugins.sh:41`.
</issue_to_address>

### Comment 3
<location path="docs/plugin-images.md" line_range="48" />
<code_context>
+or a release train, e.g.:
+
+```text
+foca-plugin-tes-routing-distance==<version>
+```
+
</code_context>
<issue_to_address>
**Name a real plugin release**

The issue calls for a real foca-plugins release train, but the recipe's example uses a version placeholder and the page says no foca-plugins distributions are published yet. The general recipe and CI test work, but the documented foca-plugins example is not yet directly usable with a real release.
</issue_to_address>

Linked issues

#323 docs: add a derived-image recipe for plugins · 5 of 6 met

# Requirement Status Notes
1 Provide a derived-image recipe for hash-pinned plugins, including verification, scanning, and signing. ✅ Met The new Plugin images page documents the full workflow. It resolves pins with pip's dry-run report rather than pip-compile/uv and uses gh attestation verify for artifact attestations.
2 Add an empty-by-default PLUGINS build argument as a convenience for local builds, documented as not hash-pinned. ✅ Met The root Dockerfile installs the argument and runs pip check; Docker Compose passes the host value through, and the docs distinguish this from the deployment recipe.
3 Show the derived image together with plugin configuration in the chart README, without adding chart install logic. ✅ Met The deployment README example sets protes.image and the plugin allowlist together; no plugin installation logic is added to the chart.
4 Do not publish an image variant containing all plugins. ✅ Met The new page says published proTES images contain only built-in plugins and explains why there is no all-plugins image.
5 Build a derived image with a test plugin and verify proTES loads it through the allowlist. ✅ Met The CI smoke step builds an image with the test distribution, enables the plugin, and checks that a new task receives its tag.
6 Name a real foca-plugins release train in the recipe. 🟡 Partly met The page describes the planned foca-plugins distributions and trains, but says none are published yet and uses <version> rather than naming a real release.

Sourcery assessment

Approval pending. 3 findings to address first.

Blocking findings: examples/plugin-image/resolve.sh:28, tests/smoke/plugins.sh:22, docs/plugin-images.md:48


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread examples/plugin-image/resolve.sh Resolved
Comment thread tests/smoke/plugins.sh Resolved
Comment thread docs/plugin-images.md Resolved
resolve.sh removes the output file before resolving, so that a failed
run cannot leave the pins of an earlier one for the build (Sourcery).

Refs #323

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@uniqueg
uniqueg merged commit e07e96d into dev Oct 31, 2026
19 checks passed
@uniqueg
uniqueg deleted the docs/323-plugin-image branch October 31, 2026 15:59
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.

docs: add a derived-image recipe for plugins

1 participant