COPY Provenance

Docker COPY directives introduce build inputs that traditionally bypass network auditing — files go directly from the host into the image layer. BuildWarden rewrites these directives so that every source file flows through the relay and gets recorded in the ledger.

How It Works

  1. The orchestrator mounts the build context into the relay container (read-only)
  2. The relay serves these files at http://cwd/<path>
  3. COPY directives in the Dockerfile are rewritten to RUN warden-io fetch commands that fetch each file from the relay
  4. Each file transfer creates a ledger entry with full hash verification

Example Transformation

Original Dockerfile:

COPY requirements.txt /app/
COPY src/ /app/src/

What actually runs:

RUN mkdir -p /app/ && warden-io fetch requirements.txt -o /app/requirements.txt
RUN mkdir -p /app/src/ && \
    printf '%s\n' 'src/main.py' 'src/lib.py' 'src/utils.py' | \
    xargs -P8 -I{} sh -c 'mkdir -p "/app/src/$(dirname "{}")" && warden-io fetch "{}" -o "/app/src/{}"'

What Gets Excluded

  • .git/ — not part of the build context
  • Files matching .dockerignore patterns

BuildWarden's own staging (/.warden in the build container) lives in a per-build temp directory, never in the context.

Concurrency

For directories with many files, downloads run with xargs -P8 (8 parallel fetches). Since transfers are over localhost to the relay, this adds negligible overhead.

Large Contexts and Tarballs

If your build context has thousands of files and you don't need per-file provenance, create a tarball first:

# In your build script, before warden build:
tar czf context.tar.gz src/

# In Dockerfile:
COPY context.tar.gz /tmp/
RUN tar xzf /tmp/context.tar.gz -C /app && rm /tmp/context.tar.gz

This produces a single ledger entry for the tarball rather than thousands of individual file entries.

Multi-stage Builds

COPY --from=<stage> directives (copies between build stages) are left unchanged — they don't reference the build context and don't need provenance tracking.

Supported Flags

FlagHandling
--chown=user:groupAppended as && chown -R user:group <dest>
--chmod=755Appended as && chmod -R 755 <dest>
--from=stageLeft as-is (multi-stage copy)

In the Ledger

Source file entries appear as:

✅ CONTEXT GET /src/main.py (1523 bytes)
✅ CONTEXT GET /src/lib.py (4201 bytes)
✅ CONTEXT GET /requirements.txt (42 bytes)

Each with full blake2b_256, sha256, sha1, and md5 hashes in the hash block.