Skip to content

fix: keep local files out of example images - #513

Merged
uniqueg merged 1 commit into
devfrom
fix/example-dockerignore
Oct 26, 2026
Merged

uniqueg merged 1 commit into
devfrom
fix/example-dockerignore

Conversation

@uniqueg

@uniqueg uniqueg commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

Summary

The example Dockerfiles copy their whole directory (COPY ./ /app), but their .dockerignore files only listed /data (and /chart). So a local .env file or config overlay ended up in the image.

  • examples/petstore/.dockerignore and examples/petstore-access-control/.dockerignore are now allowlists: *, then only the files each app needs (app.py, config.yaml, controllers, exceptions, spec, and for petstore also wsgi.py and worker.py; the policy model for the access control example).
  • The Docker section of the getting started guide recommends allowlist .dockerignore files for apps that copy their build context.

Light lane: the change touches only configuration files of the examples and docs. I reviewed the diff myself.

Closes #511

Verification

  • I built each example directory as a context with a stray .env file present (FROM busybox, COPY . /c, find /c). Only the allowlisted files were copied: 7 for petstore, 6 for petstore with access control. No .env* file was copied.
  • mkdocs build --strict: pass.
  • pre-commit: pass.
  • CI on 0487765: 26 checks pass, including the integration test, which builds and runs the petstore image; 3 are skipped as intended.

🤖 Generated with Claude Code

Summary by Sourcery

Restrict example Docker build contexts to required application files and document the recommended .dockerignore pattern.

Bug Fixes:

  • Prevent local environment files and configuration overlays from being included in the Petstore example Docker images.

Enhancements:

  • Document allowlist-based .dockerignore usage for applications that copy their entire Docker build context.

Documentation:

  • Add guidance to the getting started Docker documentation for excluding local files from images.

The example Dockerfiles copy their whole directory, and their
.dockerignore files listed only /data (and /chart), so local .env files
or config overlays ended up in the images. The .dockerignore files are
now allowlists of the files each app needs, and the getting started
guide recommends the same for apps.

Closes #511

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

sourcery-ai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

The PR prevents local .env files and configuration overlays from being included in the example images by replacing narrow ignore rules with explicit .dockerignore allowlists, and documents this Docker build-context safety pattern in the getting-started guide.

Flow diagram for allowlisted Docker build contexts

flowchart LR
    Context[Docker build context]
    Ignore[.dockerignore allowlist]
    Image[Example image]
    Local[Local .env and config overlays]
    App[Required application files]

    Context --> Ignore
    Local --> Context
    App --> Context
    Ignore -->|exclude| Local
    Ignore -->|include| App
    App --> Image
Loading

File-Level Changes

Change Details Files
Restrict example Docker build contexts to explicitly required application files, preventing local secrets and configuration overlays from entering images.
  • Convert both example .dockerignore files to deny-all allowlists.
  • Allow only each example's Python entrypoints, configuration, controllers, exceptions, API spec, and access-control policy model as applicable.
  • Retain the additional WSGI and worker files required by the petstore example.
examples/petstore/.dockerignore
examples/petstore-access-control/.dockerignore
Document the security implications of copying the entire Docker build context and recommend the allowlist pattern.
  • Explain that COPY ./ /app includes the full build context.
  • Recommend * followed by negated entries for required application files.
docs/getting-started.md

Assessment against linked issues

Issue Objective Addressed Explanation
#511 Ensure images built from the petstore and petstore-access-control examples exclude local .env files and config overlays from the working copy. ✅
#511 Document how to keep local files out of images when example apps copy their build context. ✅

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

@codecov

codecov Bot commented Oct 26, 2026

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff            @@
##               dev      #513   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           55        55           
  Lines         6558      6558           
=========================================
  Hits          6558      6558           
Flag Coverage Δ
test_unit 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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 26, 2026 11:13

@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 reviewed your changes and they look great!

Sourcery assessment

Approved.


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

@uniqueg
uniqueg merged commit 888fcf0 into dev Oct 26, 2026
30 checks passed
@uniqueg
uniqueg deleted the fix/example-dockerignore branch October 26, 2026 11:16
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.

fix: keep local files out of example images

1 participant