Last active
August 11, 2019 02:57
-
-
Save robearlam/9db4e18067d89d82bbb17ed5df754aa3 to your computer and use it in GitHub Desktop.
Using VSCode to debug a .NETCore application running inside a Docker container
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "3" | |
services: | |
myapp: | |
container_name: myapp | |
build: | |
context: . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM microsoft/dotnet:2.2-sdk AS build | |
WORKDIR /app | |
# copy csproj and restore as distinct layers | |
COPY *.sln . | |
COPY myapp/*.csproj ./myapp/ | |
RUN dotnet restore | |
# copy everything else and build app | |
COPY myapp/. ./myapp/ | |
WORKDIR /app/myapp | |
RUN dotnet publish -c Debug -o out | |
FROM microsoft/dotnet:2.2-aspnetcore-runtime AS runtime | |
WORKDIR /app | |
COPY --from=build /app/myapp/out ./ | |
RUN apt-get update | |
RUN apt-get install -y --no-install-recommends apt-utils | |
RUN apt-get install -y curl unzip procps | |
RUN curl -sSL https://aka.ms/getvsdbgsh | bash /dev/stdin -v latest -l /publish/vsdbg; | |
ENTRYPOINT ["dotnet", "myapp.dll"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.2.0", | |
"configurations": [ | |
{ | |
"name": ".NET Core Docker Attach", | |
"type": "coreclr", | |
"request": "attach", | |
"processId": "${command:pickRemoteProcess}", | |
"sourceFileMap": { | |
"/app": "${workspaceFolder}" | |
}, | |
"pipeTransport": { | |
"pipeProgram": "docker", | |
"pipeArgs": [ "exec", "-i", "myapp" ], | |
"debuggerPath": "/publish/vsdbg/vsdbg", | |
"pipeCwd": "${workspaceRoot}", | |
"quoteArgs": false | |
} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment