Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Development in docker - dynamic compiling

$
0
0

Hello
What is the best way of setting up a development environment using .net core and docker? From the examples I've seen, it seems that you have to redeploy everything everytime you make a code change. I'm trying to get a setup where I can do development in visual studio code + docker with debugging and without having to compile and restart the docker container

I had hoped that i could mount my local project so that docker would read the files that I work in, but I have a bit of problems with getting everything to work.
I've created a new project:

`dotnet new httpapi`

which creates a working project with a docker file:

<div style="color: #d4d4d4; background-color: #1e1e1e; font-family: 'Droid Sans Mono', 'monospace', monospace, 'Droid Sans Fallback'; font-weight: normal; font-size: 14px; line-height: 19px; white-space: pre;"> <div>FROM microsoft/aspnetcore-build:1.0-2.0 as BUILD</div> <div>COPY ./ /apps</div> <div>WORKDIR /apps</div> <div>RUN bash -c "dotnet restore ./MountAndWatchTest.csproj && dotnet publish ./MountAndWatchTest.csproj -c Release -o ./obj/Docker/publish"</div> <div>FROM microsoft/dotnet</div> <div>WORKDIR /apps</div><div>EXPOSE 80</div> <div>COPY --from=BUILD /apps/obj/Docker/publish .</div> <div>ENTRYPOINT ["dotnet", "MountAndWatchTest.dll"]</div> </div>

I have tried to:
- Mount the src directory from docker-compose
- change the docker file to:

<div style="color: #d4d4d4; background-color: #1e1e1e; font-family: 'Droid Sans Mono', 'monospace', monospace, 'Droid Sans Fallback'; font-weight: normal; font-size: 14px; line-height: 19px; white-space: pre;"> <div>FROM microsoft/dotnet</div> <div>WORKDIR /src</div> <div>EXPOSE 80</div> <div>RUN dotnet restore</div> <div>RUN dotnet run</div> </div>

The idea is to change it to "dotnet watcher run" later and hopefully get it to update on code changes.
I'm able to run 'dotnet run' locally and get a server up and running on port 5000, but when I do it in docker I get a:
'Couldn't find a project to run. Ensure a project exists in /src, or pass the path to the project using --project.'

even though it works locally.

Firstly: Am I on the right path, or is there a better way to develop through a docker container? Or should I develop locally and move it to a container at deploy time? In that case I'm worried about the environment not being the same as that is running on the server.


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>