Skip to content

Exclude .env files from the image build context #312

Closed

Description

@uniqueg

Found in the whole-repo pre-release review for v1.0.0rc1 (finding L3).

Problem

.dockerignore is an allowlist that re-includes all of cloud_registry/, but it does not exclude .env files. A local cloud_registry/.env (or any .env.* file in an included path) would reach the build context and the build-stage layer and cache (COPY cloud_registry /tmp/src/cloud_registry). The final image is not affected (it installs only the wheel). This still breaks the org rule that every repo that builds an image excludes .env* (except .env.example) from the build context.

Fix

  • Append **/.env* to .dockerignore (also covers .envrc, .env-prod). Updated after review: .env.example is not re-included, since the build copies no example and a wildcard exception (!**/.env.example) makes BuildKit walk all excluded directories; a plain !cloud_registry/.env.example can be added if a build ever needs one.
  • Test in tests/test_image_build.py.

Activity

  1. added this to the v1.0.0-rc1 milestone on Nov 1, 2026
  2. added
    priority: high
    status: triage
    type: security
    workload: minutes
    status: in progress
    and removed
    status: triage
    on Nov 1, 2026
  3. removed
    status: in progress
    on Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: hightype: securityworkload: minutes

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions