Skip to content

Conversation

@ronit-1404
Copy link

Fixes #4632

Tasks

  • Reviewed contribution guidelines
  • PR is descriptively titled 📑 and links the original issue above 🔗
  • Tests pass -- look for a green checkbox ✔️ a few minutes after opening your PR
    Run tests locally to check for errors.
  • Commits are in uniquely-named feature branch and has no merge conflicts 📁
  • Updated documentation pages (if applicable)
  • Updated CHANGELOG.rst (if applicable)

Description

This PR optimizes the Dockerfile by restructuring COPY commands to improve Docker layer caching efficiency, resulting in significantly faster build times.

Changes Made

  • Replaced single COPY . /scancode-toolkit with selective, ordered COPY commands
  • Copy configuration and source files before running ./configure
  • Copy runtime files after configuration completes
  • Improved layer caching to prevent invalidation of expensive configure step

Technical Details

The Dockerfile previously copied all files at once before running configuration, causing any file change to invalidate the expensive configure layer. Now it selectively copies files in optimal order for better caching.

Benefits

✅ Faster Docker builds when documentation or non-essential files change
✅ Better layer cache utilization following Docker best practices
✅ Reduced CI/CD pipeline execution time
✅ Improved developer experience during local Docker builds
✅ Cost savings on cloud-based build systems

Impact

No functional changes to the Docker image or scancode behavior. This is purely a build optimization that maintains identical runtime behavior while improving build performance.

Signed-off-by: Ronit ronitdhase@gmail.com

@ronit-1404
Copy link
Author

@AyanSinhaMahapatra review this please.

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.

Optimize Dockerfile layer caching to improve build performance

1 participant