Closed Freakazoid182 closed 2 years ago
Ok I already figured out what I was doing wrong.
I thought the /src
folder was mounted on the folder where the DockerfileFile
build property was set to, but it's actually set to DockerfileContext
property. This is a relative path to the DockerfileFile
path. So setting the DockerfileContext
property to the folder containing wwwroot
for the project I wanted to run resolves the issue.
I still think there's scenario's where you still need to be able to override where /src
is mapped to.
I hope this issue might help someone else running into a similar problem ✌
I found that the following setup doesn't work:
For .NET 6 AspNetCore (maybe .NET 5 too) projects, the container tools create a
(project_name).staticwebassets.runtime.CT.json
file in the output folder if you have awwwroot
folder in your project.It sets a
ContentRoots
path to/src/wwwroot
. This is to ensure that the application running in the container knows where to service the static file asset from. The original(project_name).staticwebassets.runtime.json
contains a Windows path, so the container tools override to theCT.json
file by setting environment variableASPNETCORE_STATICWEBASSETS="/app/bin/{project name}.staticwebassets.runtime.CT.json"
on thedocker exec
command that starts the application in the container.The issue is that the
/src
folder is always mounted to the folder where theDockerfile
is, which isn't necessarily the project folder containingwwwroot
too.In my case I have multiple projects which I want to share a single
Dockerfile
with, which I reference through theDockerfileFile
build property, by configuring it to aDockerfile
in a parent folder. The end result is that the you get aSystem.IO.DirectoryNotFoundException: /src/wwwroot/
exception at startup.So my specific situation is:
wwwroot
folderDockerfile
which is not in the same folder where thewwwroot
folder is (the folder which is mounted on/src
)DockerfileFile
build property set to where theDockerfile
actually is (a parent folder of the project)I couldn't find any configuration to set the folder which should be mounted to the
/src
folder on the container. It would be nice if the container tools allow to override this value like with other build properties.Maybe I'm just doing something which isn't actually supported, but it feels like it should be possible. Or maybe I'm just overlooking a setting that's already available. Any help would be greatly appreciated.
Here's an example of my
(project_name).staticwebassets.runtime.CT.json
file: