What the agent does
The agent reads the solution before it writes a line of Dockerfile. In a .NET solution like jasontaylordev/CleanArchitecture, global.json pins SDK 10.0.403 with rollForward: latestFeature; Directory.Build.props sets net10.0, TreatWarningsAsErrors and an ArtifactsPath of artifacts/ at the root, so build output never lands in bin/ and obj/; Directory.Packages.props manages every package version centrally; and CleanArchitecture.slnx lists seven projects under src/, with Web.csproj referencing Application, Infrastructure and ServiceDefaults. Web.csproj carries a PublishRunWebpack target that runs npm install and npm run build -- --configuration production in ClientApp/ during publish and copies dist/browser into wwwroot; ClientApp/package.json is an Angular app whose prebuild script runs nswag run /runtime:Net100 to generate the TypeScript client from the built API. Program.cs calls InitialiseDatabaseAsync() only when the environment is Development and UseHsts() otherwise, adds UseHttpsRedirection, serves the SPA with UseFileServer and MapFallbackToFile("index.html"), and ServiceDefaults maps /health and /alive only in Development. appsettings.json points the SQLite connection at DataSource=CleanArchitecture.db;Cache=Shared, and launchSettings.json listens on 5000 and 5001. The repository has no Dockerfile, no .dockerignore and no compose file; .github/workflows/build.yml restores, builds in Release with Node 26 and runs the tests, and src/AppHost is an Aspire 13 host that models the same Web project for aspire run.
The Dockerfile goes at the repository root, because the build needs global.json, the two Directory.*.props files and the sibling projects, and its first stage is mcr.microsoft.com/dotnet/sdk:10.0, which matches global.json. The agent installs Node at the major CI uses from NodeSource into that stage, copies the root files and every .csproj first and runs dotnet restore src/Web/Web.csproj so the restore layer is cached until a package changes, then copies the rest and runs dotnet publish src/Web/Web.csproj -c Release -o /app/publish. That publish runs the PublishRunWebpack target, so the Angular build and the NSwag client generation happen inside the image build, against the Web assembly the same publish has just compiled. The final stage is mcr.microsoft.com/dotnet/aspnet:10.0, copies /app/publish, switches to the image's non-root app user, exposes 8080, the port the runtime image listens on by default, and starts dotnet CleanArchitecture.Web.dll. A .dockerignore leaves out artifacts/, .git, every node_modules and bin and obj directory, so the context stays small and a local build never leaks into the image.
Two things in Program.cs decide how the container runs, and the agent writes both down rather than papering over them. The SQLite file would sit inside the container's writable layer and vanish with it, so the Dockerfile declares a /data volume and sets ConnectionStrings__CleanArchitectureDb to a path under it. Migrations and seeding run only in Development, so a container started with the default Production environment has an empty database until someone runs them; the pull request states this and offers two options, running with ASPNETCORE_ENVIRONMENT=Development for a first boot or a small startup flag that applies migrations in any environment, and takes neither without a reviewer's say.
Then it builds and runs the image. The sandbox has no Docker, so the agent installs docker.io with apt and starts dockerd, runs docker build, starts the container with the volume mounted and ASPNETCORE_ENVIRONMENT=Development, and requests /, /scalar and /health to confirm the SPA, the API reference and the health check answer. It records the image size and the build time of a second, cached build, and adds a short section to README.md with the build and run commands.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "Add a Dockerfile for the Web project of this .NET solution. Read global.json, Directory.Build.props, Directory.Packages.props, the solution file, src/Web/Web.csproj, src/Web/Program.cs, src/Web/ClientApp/package.json, src/ServiceDefaults, appsettings.json and the build workflow first. Write a multi-stage Dockerfile at the repository root: an SDK stage matching global.json with Node installed at the major the workflow uses, a restore layer that copies only the props, global.json and project files, then dotnet publish of src/Web in Release, and an aspnet runtime stage that runs as the non-root app user on the image's default port. Add a .dockerignore that excludes artifacts, .git, node_modules, bin and obj. Put the SQLite database on a declared volume through the connection-string environment variable. Note how Program.cs gates migrations and health endpoints on the Development environment and present the options in the pull request instead of changing the code. Install Docker in the sandbox, build the image, run it, and request the SPA, /scalar and /health. Add build and run commands to the README and open a pull request with the build output and what each request returned.",
"resources": [
{
"url": "https://github.com/your-org/your-app"
}
]
}- Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
- Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
- Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.
What comes back
A pull request with Dockerfile, .dockerignore and a README section. Its description shows the docker build output with each stage, the image size, the three HTTP requests against the running container with their status codes, and a short list of what the container needs from the operator: the volume for the database and a decision on how migrations run outside Development.
A reviewer checks that the restore layer copies every project file the Web project depends on, so a change under src/Domain does not invalidate the package cache, that the Angular build ran inside the image rather than being copied from a laptop, and that nothing in the image runs as root. Merging gives the team an image to run anywhere; the Aspire host under src/AppHost is unchanged and still models the same project for local runs.
Run it on every terminal hand-off
A developer who needs the image before a deployment review starts this from the terminal with this body and the repository in resources, then goes back to the feature they were on. The run reads the real project files and the real Program.cs, so the Dockerfile fits this solution's artifacts path and SPA build rather than a generic template.
Send a request_id, a UUID, with the body so a retried start returns the run it already began. When the turn ends, GET /o/{org}/sessions/{id} names the pull request, and a follow-up to the same session can ask for a compose file with Postgres from appsettings.PostgreSQL.json, or for the migration flag the pull request described.
The use case this job follows, with its automation and trigger: Hand off a long task.
Why run it on Rush?
A Dockerfile that has not been built proves nothing, and building this one means the SDK, Node for the Angular stage, a NuGet restore and a publish that runs NSwag, then a container that actually answers. The agent does all of that in its own sandbox, with Docker installed inside it, and keeps the build log and each request in the run's record, so the pull request shows an image that ran.
The same run fits any .NET solution: a minimal API with no SPA, a Blazor Server app, a worker service. Each gets a Dockerfile shaped by its own project references, publish targets and configuration, and a run that proves the image starts.
Frequently asked questions
Why not let Aspire publish the container?
src/AppHost models the Web project for aspire run and an Azure Container Apps environment, and Aspire can produce images from that model. A Dockerfile is for teams that build and ship the Web project on their own CI or registry; it does not change the AppHost, and both can coexist.
Does the image build the Angular app?
Yes. dotnet publish runs the project's PublishRunWebpack target, which runs npm install and the production ng build in ClientApp and copies the output into wwwroot. That is why the SDK stage installs Node; the runtime stage has none.
Why does the database need a volume?
The default connection string is a SQLite file next to the app. In a container that file lives in the writable layer and is lost when the container is replaced. The Dockerfile declares /data and points the connection string there through ConnectionStrings__CleanArchitectureDb, so the file survives restarts.
Will migrations run when the container starts?
Only when ASPNETCORE_ENVIRONMENT is Development, because Program.cs calls the initialiser inside that check. The run leaves the code alone and lists two ways forward in the pull request; picking one is a reviewer's call, and a follow-up can implement it.