dotnet / aspire

An opinionated, cloud ready stack for building observable, production ready, distributed applications in .NET
https://learn.microsoft.com/dotnet/aspire
MIT License
3.78k stars 439 forks source link

Docker image is not being built when using `AddDockerFile` #5052

Closed SWarnberg closed 2 months ago

SWarnberg commented 2 months ago

Is there an existing issue for this?

Describe the bug

Since Azure Functions is not yet supported in Aspire, I thought that creating a Dockerfile in the Function project would give me better control in the deployed App. I get problems when Aspire deploys the project (like the gRPC error).

However, referencing the documentation at https://learn.microsoft.com/en-us/dotnet/aspire/app-host/withdockerfile, which states that you can specify a Dockerfile to build when the app host is starting, the Docker image is not being built.

I've added the following to the app host project:

builder.AddDockerfile("orders-functions", "../", "Orders.Functions/Dockerfile")
  .WithReference(orderDb);

When running the project, I can clearly see that the image is not being built. Instead, the console shows the following error, which indicates that the image should already exist.

fail: Aspire.Hosting.Dcp.dcpctrl.ContainerReconciler[0]
      could not create the container    {"Container": {"name":"orders-functions-vvcfhwtf"}, "Reconciliation": 8, "error": "CreateContainer command returned error code 1 Stdout: '' Stderr: 'Unable to find image 'orders-functions-image-bad8fa60d770c3ca8865d4b2b9fd99a6210f915d:latest' locally\nError response from daemon: pull access denied for orders-functions-image-bad8fa60d770c3ca8865d4b2b9fd99a6210f915d, repository does not exist or may require 'docker login': denied: requested access to the resource is denied\n'"}

Expected Behavior

According to the documentation, the docker image should be built when the app host is running. Or is there a step in the documentation that is missing?

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version info

No response

Anything else?

davidfowl commented 2 months ago

Did you update everything?

SWarnberg commented 2 months ago

Frameworks and packages? Yes, everything on latest version (as of today).

rocklau commented 2 months ago

Same issue, <PackageReference Include="Aspire.Hosting.AppHost" Version="8.1.0" />

But playground withdockerfile in source code is ok.

The image build workflow may not be invoked.

davidfowl commented 2 months ago

Did you update the workload?

ronnygunawan commented 2 months ago

I updated the workload to 8.1.0. Didn't resolve the problem.

rocklau commented 2 months ago

fixed now.sudo dotnet workload update

rocklau commented 2 months ago

Thanks guys.

mhenry-cb commented 2 months ago

For me, I had to update the workload and update Visual Studio from 17.10.4 to 17.10.5, and then it worked. (Package references were already up-to-date.)

SWarnberg commented 2 months ago

Yes, now it works with latest workloads and versions.