-
Notifications
You must be signed in to change notification settings - Fork 598
Closed
Description
I followed the recipe for setting up debugger for a Node-Typescript application inside Docker.
For some reason it is not working.
Below is my configuration as follows:
package.json (only scripts part):
{
"scripts": {
"tsc": "tsc -p ./tsconfig.json",
"start": "node --no-lazy ./dist/server.js",
"debug": "nodemon",
"docker-compose-debug": "docker-compose up --force-recreate"
}nodemon.json:
{
"verbose": true,
"ignore": ["*.spec.ts", "*.js"],
"execMap": {
"js": "node --no-lazy --inspect-brk=9229"
},
"watch": "./dist",
"ext": "js"
}docker-compose:
version: '2.1'
services:
cdt_box:
container_name: cdt_box
restart: always
build: .
image: app:dev
entrypoint: ["npm", "run", "debug"]
volumes:
- ./dist:/server/dist
ports:
- 4000:4000
- 9229:9229
depends_on:
- mongodb
links: # soon deprecated
- mongodb
mongodb:
image: mongo:3.6
container_name: mongo
volumes:
- ./data/db:/data/db
ports:
- 27018:27017tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"label": "tsc-watch",
"type": "typescript",
"tsconfig": "tsconfig-dev.json",
"problemMatcher": ["$tsc-watch"],
"isBackground": true,
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"reveal": "always",
"panel": "new"
}
}
]
}
launch.json
Do I need to add "address: localhost" in the 2nd configuration (attach)?
When I launch with "Launch Docker via npm" I can see that mongoose connects successfully and am able to hit the server with Postman. However the debugger times out.
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Docker via npm",
"preLaunchTask": "tsc-watch",
"runtimeExecutable": "npm",
"runtimeArgs": ["run", "docker-compose-debug"],
"localRoot": "${workspaceFolder}",
"remoteRoot": "/server",
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"protocol": "inspector",
"port": 9229,
"timeout": 60000,
"sourceMaps": true,
"restart": true
},
{
"type": "node",
"request": "attach",
"name": "Docker: Attach to Node",
"preLaunchTask": "tsc-watch",
"localRoot": "${workspaceFolder}",
"remoteRoot": "/server",
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
"internalConsoleOptions": "openOnFirstSessionStart",
"restart": true,
"sourceMaps": true,
"port": 9229,
"protocol": "inspector"
},
{
"type": "node",
"request": "launch",
"name": "nodemon-npm",
"preLaunchTask": "tsc-watch",
"cwd": "${workspaceFolder}",
"runtimeExecutable": "npm",
"program": "${workspaceFolder}/dist/server.js",
"runtimeArgs": ["run-script", "debug"],
"restart": true,
"sourceMaps": true,
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"protocol": "inspector",
"port": 9229
}
]
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels