Skip to content

Publish aspnetapp-non-root sample images#4542

Closed
lbussell wants to merge 1 commit intodotnet:mainfrom
lbussell:issue-4520
Closed

Publish aspnetapp-non-root sample images#4542
lbussell wants to merge 1 commit intodotnet:mainfrom
lbussell:issue-4520

Conversation

@lbussell
Copy link
Member

@lbussell lbussell commented Apr 4, 2023

Fixes #4520

@mthalman
Copy link
Member

mthalman commented Apr 4, 2023

Build error:

---> System.InvalidOperationException: A value was not found for the ARG '$BUILDPLATFORM' in 'samples/aspnetapp/Dockerfile.alpine-non-root'

Oh no! Our lovely Dockerfile isn't incompatible with our own infrastructure.

@richlander - Do you mind if we remove the usage of $BUILDPLATFORM and $TARGETARCH from Dockerfile.alpine-non-root? This pattern isn't applied consistently to the Dockerfiles anyway. We'd need to make changes to Image Builder in order to support the use of implicit variable references in the FROM instruction.

@richlander
Copy link
Member

That's unfortunate. I referenced that Dockerfile in this post: https://devblogs.microsoft.com/dotnet/improving-multiplatform-container-support/. Should I make a new one that is multi-arch specific and then update the link?

@mthalman
Copy link
Member

mthalman commented Apr 4, 2023

Actually, I think we can get this to work with a small amount of work.

@lbussell - The regex used to parse the FROM instruction needs to be updated here in Image Builder: https://github.com/dotnet/docker-tools/blob/e9b03f39e46cbc6527c416af041747ec466c4c86/src/Microsoft.DotNet.ImageBuilder/src/ViewModel/PlatformInfo.cs#L23

It needs to account for a --platform option existing in the instruction, essentially ignoring that so that it can get the image name.

@mthalman
Copy link
Member

mthalman commented Apr 5, 2023

The build error may be caused by the lack of customBuildLegGroups for the new entries in the manifest. I didn't think it was needed, but it might be the reason that the matrix generation is getting screwed up. I would try adding customBuildLegGroups to those entries, copying from the other ones, to see if that fixes things.

@mthalman
Copy link
Member

mthalman commented Apr 6, 2023

The change to the matrix type should not be necessary, nor it is desired. Did my suggestion above not work in your testing?

@mthalman
Copy link
Member

mthalman commented Apr 6, 2023

Build error says failed to parse platform : "" is an invalid component of "": platform specifier component must match "^[A-Za-z0-9_-]+$": invalid argument

I think this is because BuildKit is not enabled by default on the build agents. I think we can workaround this by adding the following to the top of the sample Dockerfile:

# syntax=docker/dockerfile:1

@richlander
Copy link
Member

That would be unfortunate to have to add. These images are intended to be best practice and that directive doesn't seem otherwise needed. Certainly, if we need that as a temporary measure, that's fine.

@lbussell
Copy link
Member Author

lbussell commented Apr 6, 2023

That would be unfortunate to have to add. These images are intended to be best practice and that directive doesn't seem otherwise needed. Certainly, if we need that as a temporary measure, that's fine.

That's alright, it still doesn't work even with the directive.

@mthalman
Copy link
Member

mthalman commented Apr 6, 2023

I think this will require a change to Image Builder then to explicitly ensure BuildKit is enabled so that it executes commands like this: DOCKER_BUILDKIT=1 docker build ...

Minor fixes to fix sample build & test

Update imagebuilder ahead of dependency flow

Add metadata for new images

Try platformVersionedOs matrix type

Revert "Try platformVersionedOs matrix type"

This reverts commit 690aa99.

Add customBuildLegGroups for non-root samples

Add back dependencies to customBuildLegGroups

Add dockerfile syntax directive
@mthalman
Copy link
Member

mthalman commented May 3, 2023

Still getting the same error. I don't think the buildkit changes have flowed in yet. dotnet/docker-tools#1129 is still open.

@lbussell
Copy link
Member Author

lbussell commented May 5, 2023

New ImageBuilder should come in with #4599.

@mthalman
Copy link
Member

This is blocked after the need to revert the build kit change in dotnet/docker-tools#1134. That's required in order to finish this work. Since that work is planned for any time soon, we'll just close this for now.

@mthalman mthalman closed this May 31, 2023
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.

Publish non-root sample in MCR

3 participants