microsoft / microsoft/aspire

publishAsDockerFile: dockerfilePath resolution relative to context is confusing

Open
#15,875 2 comments 0 reactions 0 assignees View on GitHub
area-app-model aspirifridays
Dominant language
C#
Stars
6.3k
Forks
991
Avg merge
2d 15h
Merged PRs (30d)
196

Description

## Description

When using `publishAsDockerFileWithConfigure`, the `dockerfilePath` parameter in `withDockerfile(contextPath, { dockerfilePath })` is relative to the Docker build context, not to the Aspire apphost directory. This is confusing and required trial and error to figure out.

For example, with a Dockerfile at the repo root and the apphost in `aspire/`:

\\\ ypescript
// From aspire/apphost.ts:
await container.withDockerfile("../", { dockerfilePath: "Dockerfile.aspire" });
// ✅ Works: dockerfilePath is relative to contextPath ("../")

await container.withDockerfile("../", { dockerfilePath: "../Dockerfile.aspire" });
// ❌ Fails: tries to find it relative to context, goes up one more level
\\\

## Expected behavior

- The behavior should be clearly documented
- Consider making `dockerfilePath` relative to the apphost directory (more intuitive for the developer) or accepting absolute paths
- At minimum, improve the error message when the Dockerfile can't be found to show the resolved path

## Environment

- Aspire SDK: 13.2.1 (TypeScript)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.