Skip to content

Dockerfiles aren't rebuilt when there are changes to dependent Dockerfiles #1525

@sbomer

Description

@sbomer

There seems to be some problem with the caching logic. Touching a Dockerfile causes it to be rebuilt, but in some cases images that depend on the rebuilt one don't get rebuilt. Context from dotnet/dotnet-buildtools-prereqs-docker#1313:

when I added LoongArch in this file and touched cross/loongarch, it didn't located the new architecture. It required us to also touch crossdeps-llvm

@mthalman is this expected? I would have thought that if I touch crossdeps-builder, images which depend on it (like crossdeps-llvm) would get rebuilt too. This seems like it might be a bug.

I suspect it is related to the use of multistage dockerfiles. Maybe the caching logic only checks the base image of the last stage here:

private async Task<bool> IsBaseImageDigestUpToDateAsync(
PlatformInfo platform,
PlatformData srcPlatformData,
ImageDigestCache imageDigestCache,
ImageNameResolver imageNameResolver,
bool isLocalImageExpected,
bool isDryRun)
{
_loggerService.WriteMessage();
if (platform.FinalStageFromImage is null)
{
_loggerService.WriteMessage($"Image does not have a base image. By default, it is considered up-to-date.");
return true;
}
string queryImage = imageNameResolver.GetFinalStageImageNameForDigestQuery(platform);

Related: #1270

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions