microsoft / microsoft/aspire

No way to pass Docker build args through YARP static files publishing to the source resource build

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

Description

## Is there an existing issue for this?

- [x] I have searched the existing issues

## Describe the bug

When using `PublishWithStaticFiles` or `PublishAsStaticWebsite` to serve static assets from a JS app through YARP, there's no way to pass Docker build arguments to the build that produces the static assets.

### The problem

Many JS frameworks need build-time configuration via Docker build args (e.g., `VITE_API_URL`, `NEXT_PUBLIC_API_URL`). These are baked into the JS bundle at build time and can't be set via runtime environment variables.

Currently:
- `WithBuildArg(name, object?)` is `[AspireExportIgnore]` (not available in polyglot) and constrained to `ContainerResource`
- `WithBuildArg(name, ParameterResource)` is exported but also constrained to `ContainerResource`
- A `ViteAppResource` / `JavaScriptAppResource` extends `ExecutableResource`, not `ContainerResource`, so neither overload is callable on the JS resource directly
- The YARP resource's `PublishWithStaticFiles`/`PublishAsStaticWebsite` generates the Dockerfile internally with no way to inject build args

### Open design question

It's not clear where build args should be set:
1. **On the source resource** — decorate the JS resource's `WithDockerfileFactory` / Dockerfile build with args before YARP consumes it via `COPY --from`
2. **Pass-through on YARP** — add an API on `PublishWithStaticFiles` / `PublishAsStaticWebsite` to forward build args to the static asset build stage
3. **Both** — let the source resource own its build args, but also allow YARP to inject additional ones

## Expected Behavior

There should be a way to pass build-time arguments (like `VITE_API_URL`) into the Dockerfile build that produces static assets, whether that's on the JS resource itself or passed through YARP's publishing methods.

## Anything else?

Related:
- #15859 (Dockerfile customization gaps in PublishWithStaticFiles / PublishAsStaticWebsite)
- #15858 (WithDockerfileBuilder not available in polyglot AppHosts)

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.