CI Perf Lint

docker-cache-copy-path-mismatch

Detects Dockerfiles that COPY a Gradle or Maven build configuration file that does not exist in the repository, when an alternative with a different extension does exist.

Why it matters

Dockerfiles often use an early COPY instruction to prime dependency caches before the full source copy:

COPY build.gradle.kts .
RUN gradle build -x bootJar

If build.gradle.kts does not exist but build.gradle does, the cache layer is broken — it copies a non-existent file (or fails silently depending on buildkit settings) and the dependency cache is never primed.

This is common after a Gradle Groovy-to-Kotlin migration where the Dockerfile was not updated.

Detection

Reports when:

Supported file pairs

COPY sourceAlternative
build.gradlebuild.gradle.kts
build.gradle.ktsbuild.gradle
settings.gradlesettings.gradle.kts
settings.gradle.ktssettings.gradle

Exclusions

Does not report when:

Severity

warning — the cache layer almost certainly does not work as intended.