Skip to content

Clarify differences between AddDockerfile and WithDockerfile methods #4050

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

Merged
merged 3 commits into from
Jul 17, 2025

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jul 15, 2025

The "Add Dockerfiles to your .NET app model" documentation previously mentioned both AddDockerfile() and WithDockerfile() methods without explaining their differences, when to use each, or whether they create Dockerfile files.

This PR adds clear explanations that address the confusion:

Key improvements:

  1. Clear definitions in introduction: Added explanations that AddDockerfile creates new container resources while WithDockerfile customizes existing ones

  2. New "When to use" section: Provides specific guidance on choosing the appropriate method:

    • Use AddDockerfile for custom containerized services
    • Use WithDockerfile to customize existing .NET Aspire components
  3. Clarifies Dockerfile expectations: Explicitly states that neither method creates Dockerfile files - both expect existing Dockerfiles in the specified context path

  4. Enhanced examples: Improved the PostgreSQL example with comments explaining the customization behavior

Before:

With .NET Aspire it's possible to specify a Dockerfile... using either the AddDockerfile or WithDockerfile extension methods.

After:

These two methods serve different purposes:
- AddDockerfile: Creates a new container resource from an existing Dockerfile...
- WithDockerfile: Customizes an existing container resource...

Both methods expect an existing Dockerfile in the specified context path—neither method creates a Dockerfile for you.

The changes are minimal (28 lines added, 2 modified) and maintain the existing document structure while directly addressing the user's confusion.

Fixes #1824.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.


Internal previews

📄 File 🔗 Preview link
docs/app-host/withdockerfile.md docs/app-host/withdockerfile

@Copilot Copilot AI changed the title [WIP] Page "Add Dockerfiles to your .NET app model" should explain AddDockerfile vs WithDockerfile Clarify differences between AddDockerfile and WithDockerfile methods Jul 15, 2025
@Copilot Copilot AI requested a review from IEvangelist July 15, 2025 17:16
Copilot finished work on behalf of IEvangelist July 15, 2025 17:16
@Copilot Copilot AI requested a review from IEvangelist July 16, 2025 18:35
Copilot finished work on behalf of IEvangelist July 16, 2025 18:35
@IEvangelist IEvangelist marked this pull request as ready for review July 16, 2025 19:22
@IEvangelist IEvangelist requested review from tdykstra and adegeo July 16, 2025 19:23
@IEvangelist IEvangelist merged commit a3349a1 into main Jul 17, 2025
9 checks passed
@IEvangelist IEvangelist deleted the copilot/fix-1824 branch July 17, 2025 13:57
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.

Page "Add Dockerfiles to your .NET app model" should explain AddDockerfile vs WithDockerfile
3 participants