dotnet / docker-tools

This is a repo to house some common tools for our various docker repos.
MIT License
124 stars 46 forks source link

Enable BuildKit in ImageBuilder #1132

Closed lbussell closed 1 year ago

lbussell commented 1 year ago

This is needed to facilitate https://github.com/dotnet/dotnet-docker/issues/4447 and https://github.com/dotnet/dotnet-docker/pull/4542

dotnet-issue-labeler[bot] commented 1 year ago

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

mthalman commented 1 year ago

I'm concerned that this may have affected the metadata of the outputted image. It doesn't look like the architecture variant is getting set for the built image (specific to Arm). This build result is an example of the issue.

Unhandled exception: System.InvalidOperationException: Platform 'Dockerfile.az.linux' is configured with an architecture that is not compatible with the base image 'mcr.microsoft.com/dotnet-buildtools/image-builder:linux-arm64':
Manifest platform:
    Architecture: ARM64
    Variant: v8
Base image:
    Architecture: ARM64
    Variant: 

@lbussell - Can you investigate this?

lbussell commented 1 year ago

Couple findings -

  1. I tried building an arm64 image on my Windows machine with Docker Desktop which has buildkit enabled by default. Produced an arm64v8 image from mcr.microsoft.com/dotnet/runtime-deps:7.0-alpine3.17-arm64v8 and it kept the v8 in the variant. I checked by running docker inspect -f "{{ .Architecture }}/{{ .Variant }}" $image like the pipeline.
  2. I pulled the offending arm64v8 ImageBuilder from the dotnetdocker ACR staging location and it still had the correct variant. I pulled the exact ImageBuilder tag (mcr.microsoft.com/dotnet-buildtools/image-builder:linux-arm64-2174742) and verified it still had the correct v8 variant. Thinking about it more this is expected, because when we use the new ImageBuilder to produce itself, it drops the v8 variant off of the new image. The existing images have the correct variant or else they wouldn't have made it through CI.

I also retried failed jobs on that pipeline and it still had the same error. This feels like a bug somewhere in ImageBuilder and requires more investigation, so for now I have prepared a PR that reverts the BuildKit changes: https://github.com/dotnet/docker-tools/pull/1136