Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable using docker build --platform switch (easily) #30369

Closed
Tracked by #31281
richlander opened this issue Feb 6, 2023 · 5 comments
Closed
Tracked by #31281

Enable using docker build --platform switch (easily) #30369

richlander opened this issue Feb 6, 2023 · 5 comments
Assignees
Labels
Area-NetSDK good first issue Issues that would be a good fit for someone new to the repository. Narrow in scope, well-defined. help wanted Issues that we would accept external contributions on. Also known as up-for-grabs. User Story A single user-facing feature. Can be grouped under an epic.
Milestone

Comments

@richlander
Copy link
Member

This is a specific aspect of: dotnet/dotnet-docker#4388

We constructed a "hero Dockerfile" that we want to offer users, but it doesn't work, sadly. There are multiple points of incompatibility that we need to resolve. See the other issue for more context.

For the SDK/CLI, it comes down to Docker's and .NET's syntax/symbols for architecture not matching.

Docker archs: 

  • amd64
  • arm64
  • arm

.NET RID archs:

  • x64
  • arm64
  • arm

The archs mostly match across the two systems, except for the first one. We need the RID in -r linux/am64 to be translated to linux/x64. No other change is needed (at least that we've discovered).

We only need this for Linux, for two reasons:

  • The ENVs we are using are only offered via Linux and buildkit. Windows doesn't use buildkit.
  • Cross-architecture docker isn't yet a scenario for Windows containers.
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-NetSDK untriaged Request triage from a team member labels Feb 6, 2023
@baronfel
Copy link
Member

baronfel commented Feb 6, 2023

When adding this mapping, we should cover -r/--runtime, and -a/--arch, but not values for RuntimeIdentifier passed explicitly via MSBuild properties (-p RuntimeIdentifier=linux-amd64).

We should try to tackle this only in the CLI handling of these options, because we are unable to handle them in the build itself. By the time the CLI invokes MSBuild, the RID (if any) has been set as a MSBuild Global Property, so it's unable to be modified.

@baronfel baronfel added good first issue Issues that would be a good fit for someone new to the repository. Narrow in scope, well-defined. help wanted Issues that we would accept external contributions on. Also known as up-for-grabs. and removed untriaged Request triage from a team member labels Feb 6, 2023
@baronfel baronfel added this to the 8.0.1xx milestone Feb 6, 2023
@richlander
Copy link
Member Author

I forgot about -a for this. That's actually a great point. We should probably switch our examples to -a since that's simpler. As long as SDK and runtime match (like Debian and Debian or Alpine and Alpine), everything will work great. Note that I realize that mixing Debian and Ubuntu will also work fine.

@richlander
Copy link
Member Author

In fact, if it made the feature simpler, I think we might be happy with support for just -a. Is that a good idea?

@mthalman

@baronfel
Copy link
Member

baronfel commented Feb 7, 2023

I think the amount of work difference for -r and -a is pretty negligible, so we should go ahead and do both. There's already an UX inconsistency between CLI options and MSBuild Properties for RuntimeIdentifier so I'd prefer to make sure the CLI options behave as uniformly as possible.

@richlander
Copy link
Member Author

I was just playing with this and realized that -a doesn't work with dotnet restore.

I'd love for -a to be our guidance for Dockerfiles, however, we'd need that to work for dotnet restore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-NetSDK good first issue Issues that would be a good fit for someone new to the repository. Narrow in scope, well-defined. help wanted Issues that we would accept external contributions on. Also known as up-for-grabs. User Story A single user-facing feature. Can be grouped under an epic.
Projects
None yet
Development

No branches or pull requests

3 participants