diff --git a/.gitignore b/.gitignore index 065c614..7292033 100644 --- a/.gitignore +++ b/.gitignore @@ -11,8 +11,9 @@ obj/ *.log # VS Code -.vscode/ -!.vscode/extensions.json +#.vscode/ +#!.vscode/extensions.json +.vscode/extensions.json !.vscode/launch.json !.vscode/tasks.json diff --git a/.vscode/docker-compose.debug.yml b/.vscode/docker-compose.debug.yml new file mode 100644 index 0000000..ff69307 --- /dev/null +++ b/.vscode/docker-compose.debug.yml @@ -0,0 +1,9 @@ +services: + worktracker: + entrypoint: + - /bin/sh + - -c + command: + - while sleep 1000; do :; done + healthcheck: + disable: true \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..2b0caf4 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,61 @@ +{ + "version": "0.2.0", + "compounds": [ + { + "name": "WorkTracker: Debug in Docker", + "configurations": [ + "WorkTracker: Debug App in Docker", + "WorkTracker: Debug Edge" + ], + "stopAll": true + } + ], + "configurations": [ + { + "name": "WorkTracker: Debug App in Docker", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "WorkTracker: Docker Debug Prepare", + "postDebugTask": "WorkTracker: Docker Debug Down", + "program": "/workspace/bin/Debug/net10.0/WorkTracker.dll", + "args": [ + "--urls", + "http://+:8080" + ], + "cwd": "/workspace", + "env": { + "ASPNETCORE_ENVIRONMENT": "Development", + "ASPNETCORE_URLS": "http://+:8080", + "DOTNET_USE_POLLING_FILE_WATCHER": "1", + "UseHttpsRedirection": "false" + }, + "sourceFileMap": { + "/workspace": "${workspaceFolder}" + }, + "pipeTransport": { + "pipeProgram": "docker", + "pipeArgs": [ + "exec", + "-i", + "worktracker-dev", + "sh", + "-c" + ], + "debuggerPath": "/vsdbg/vsdbg", + "pipeCwd": "${workspaceFolder}", + "quoteArgs": false + }, + "justMyCode": true, + "requireExactSource": false, + "console": "internalConsole" + }, + { + "name": "WorkTracker: Debug Edge", + "type": "msedge", + "request": "launch", + "url": "http://localhost:8002", + "webRoot": "${workspaceFolder}", + "internalConsoleOptions": "neverOpen" + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..3edf94c --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,73 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "WorkTracker: Docker Debug Up", + "type": "shell", + "command": "docker", + "args": [ + "compose", + "-f", + "docker-compose.yml", + "-f", + "docker-compose.override.yml", + "-f", + ".vscode/docker-compose.debug.yml", + "up", + "-d", + "--build", + "worktracker" + ], + "options": { + "cwd": "${workspaceFolder}" + }, + "problemMatcher": [] + }, + { + "label": "WorkTracker: Docker Debug Build", + "type": "shell", + "command": "docker", + "args": [ + "exec", + "worktracker-dev", + "dotnet", + "build", + "WorkTracker.csproj", + "-c", + "Debug" + ], + "options": { + "cwd": "${workspaceFolder}" + }, + "problemMatcher": "$msCompile" + }, + { + "label": "WorkTracker: Docker Debug Prepare", + "dependsOrder": "sequence", + "dependsOn": [ + "WorkTracker: Docker Debug Up", + "WorkTracker: Docker Debug Build" + ], + "problemMatcher": [] + }, + { + "label": "WorkTracker: Docker Debug Down", + "type": "shell", + "command": "docker", + "args": [ + "compose", + "-f", + "docker-compose.yml", + "-f", + "docker-compose.override.yml", + "-f", + ".vscode/docker-compose.debug.yml", + "down" + ], + "options": { + "cwd": "${workspaceFolder}" + }, + "problemMatcher": [] + } + ] +} \ No newline at end of file diff --git a/README.Docker.md b/README.Docker.md index df5160d..1663df6 100644 --- a/README.Docker.md +++ b/README.Docker.md @@ -25,6 +25,14 @@ Development in Docker: - The override file keeps a containerized `dotnet watch` flow for cases where you still want Docker. - The development container mounts the workspace into `/workspace` and stores its Couchbase Lite files under `./.docker-data/couchbase-dev` on the host. +Debugging in Docker from VS Code: + +- Use the `WorkTracker: Debug in Docker` launch configuration. +- VS Code brings up the development container with `docker compose`, builds the app in `Debug`, and launches `WorkTracker.dll` under `vsdbg` inside the container. +- When the app reports that it is listening, VS Code automatically opens Microsoft Edge in browser debug mode against http://localhost:8002. +- The app remains available at http://localhost:8002 while the debugger is attached. +- Stopping the debug session runs `docker compose down` for the debug stack. + Manual development start: - `docker compose up --build` @@ -37,4 +45,4 @@ Notes: - The base compose file remains production-oriented; the override file is the optional containerized development layer. - The first container build takes longer because the dev image installs the .NET debugger. -- The Dockerfile uses the .NET 9 `*-noble` images so local builds and container builds stay aligned with the SDK available in VS Code. +- The Dockerfile uses the .NET 10 `*-noble` images so local builds and container builds stay aligned with the SDK available in VS Code.