[release/13.0] Generate fallback Dockerfile for Python apps without UV#12640
Merged
davidfowl merged 5 commits intorelease/13.0from Nov 4, 2025
Merged
[release/13.0] Generate fallback Dockerfile for Python apps without UV#12640davidfowl merged 5 commits intorelease/13.0from
davidfowl merged 5 commits intorelease/13.0from
Conversation
Contributor
Author
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 12640Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 12640" |
eerhardt
approved these changes
Nov 3, 2025
- Modified PythonAppResourceBuilderExtensions to generate Dockerfiles for all Python apps - Split Dockerfile generation into two methods: GenerateUvDockerfile and GenerateFallbackDockerfile - Fallback Dockerfiles detect requirements.txt and run pip install if present - Uses same runtime image (python:X.Y-slim-bookworm) as UV workflow for consistency - Updated PythonVersionDetector to accept nullable VirtualEnvironment parameter - Added comprehensive tests for fallback Dockerfile generation Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
…move empty line Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
a616bfb to
809b552
Compare
captainsafia
reviewed
Nov 3, 2025
|
|
||
| var pythonVersion = pythonEnvironmentAnnotation.Version ?? PythonVersionDetector.DetectVersion(appDirectory, pythonEnvironmentAnnotation.VirtualEnvironment!); | ||
| // Try to get Python environment annotation | ||
| context.Resource.TryGetLastAnnotation<PythonEnvironmentAnnotation>(out var pythonEnvironmentAnnotation); |
Contributor
There was a problem hiding this comment.
It feels weird to the discard the value of the TryGet here. It seems like we could still set the fallback Python version even if we did include the if-statement.
Member
There was a problem hiding this comment.
I think the logic that is here is what we want. Including an if on the TryGet would make the logic harder to read/follow IMO. The TryGet will output a null annotation if one isn't found, so doing the null checks seems like the easiest way.
captainsafia
approved these changes
Nov 3, 2025
davidfowl
approved these changes
Nov 4, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #12627 to release/13.0
/cc @eerhardt @copilot
Customer Impact
Previously, Dockerfiles were only generated for Python apps using UV. Non-UV Python apps had no automatic containerization support.
Testing
Added new automated tests. Manually tested the
playground\python\instrumented_scriptapp produces a docker image successfully.Risk
Only affects Python apps, and only if they aren't using UV.
Regression?
No