dotnet / dotnet/sdk-container-builds
Infer `scratch` base image for applications that are statically-linked
- Dominant language
- No language data
- Stars
- 197
- Forks
- 53
- PR merge metrics
- No merged PRs in 30d
Description
Per [this tweet](https://twitter.com/KatsuyaSawada/status/1628342391227973633) it is now possible to compile .NET applications that are static-linked and run on a distroless/scratch container. We should detect this scenario and infer scratch on the users's behalf.
A sample project file from the tweet is:
```xml
Exe
net8.0
enable
enable
false
true
false
true
false
true
avx2,bmi2, fma,pclmul, popcnt,aes
Size
true
true
true
true
true
```
## Detection conditions
Ideally _not_ all of the above boolean markers - is there something more minimal or semantic to hang off of?
Based on feedback from KatsuyaSawada, the last four booleans are the trigger. So the condition would be
```xml
<_IsStaticLinked Condition="'$(StaticExecutable)' == 'true' and
'$(StaticICULinking)' == 'true' and
'$(StaticOpenSslLinking)' == 'true' and
'$(StaticNumaLinking)' == 'true'">true
<_ContainerBaseImageName Condition="'$(_IsStaticLinked_)' == 'true'">scratch
... rest of conditions ...
```
## Blockers
We don't support `scratch` yet - I hacked this together in https://github.com/dotnet/sdk-container-builds/pull/327 but we should have a more concrete concept of deriving an image from _nothing_.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the detection conditions and the sample project file in this issue, then read the linked sdk-container-builds/pull/327 for the existing scratch experiment. The work is done when static linking is detected from the specified properties and container generation supports deriving an image from no base image.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker
- Domain
- build-system, devops
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100