I have 3 services which are dependent on each other. E.g.
main-service
depends on proxy2
. proxy2
depends on proxy1
.
All the services are running inside the docker (docker desktop in Mac) as 3 containers.
I want to debug the node Js (version 18.x) processes of all the services.
Like I want to make an API call of the main-service & want to debug main-service, then proxy2 then proxy1.
Here is my main-service docker-compose file (docker-compose.debug.yml):
version: "1.0"
services:
mysql:
image: <image>
command: mysqld
environment:
- ....
healthcheck:
test: "mysql -e status;"
proxy1:
image: proxy1:latest
environment:
- HTTP_PORT=80
ports:
- "8002:80"
- "9092:9090"
command: [ 'yarn', 'start:debug' ]
restart: always
proxy2:
image: proxy2:latest
depends_on:
- proxy1
environment:
- HTTP_PORT=80
ports:
- "8001:80"
- "9091:9090"
command: [ 'yarn', 'start:debug' ]
restart: always
main-service:
image: main-service:latest
ports:
- "8000:8000"
- "9090:9090"
depends_on:
mysql:
condition: service_healthy
proxy2:
condition: service_started
proxy1:
condition: service_started
env_file:
- .env.local
environment:
- HTTP_PORT=8000
command: [ 'yarn', 'start:debug' ]
My package.json
are:
**proxy1 package.json:**
"start:debug": "node --inspect=0.0.0.0:9092 src/index.js"
**proxy2 package.json:**
"start:debug": "node --inspect=0.0.0.0:9091 src/index.js"
**main-sercice package.json:**
"start:debug": "ENVIRONMENT=local node --inspect=0.0.0.0:9090 src/index.js"
I am firing it up as: docker-compose -f docker-compose.debug.yml up -d
I can see the respective ports are attached when checking docker logs -f
, as follows:
main-service docker log: Debugger listening on ws://0.0.0.0:9090/882edae9-6bbf-4705-afec-8285bca8f827
proxy2 docker log: Debugger listening on ws://0.0.0.0:9091/ba731ca4-d991-4288-b449-e8eb84922552
proxy1 docker log: Debugger listening on ws://0.0.0.0:9092/bc8e917d-a13b-4e42-a2fa-fd02cfbfafe1
Can see in my docker-desktop that things are properly showing up, all the containers are port-bound and running healthy.
However I am only able to Vscode debug the main-service
, running in 9090 port. Not the other services. (I am opening up multiple vscodes using duplicate workspace under File menu
and trying to run each in each vscode).
My VsCode .vscode/launch.json
:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "main-service",
"address": "0.0.0.0",
"port": 9090,
"localRoot": "${workspaceFolder}/main-service/src",
"remoteRoot": "/main-service/src",
"skipFiles": [
"<node_internals>/**"
],
},
{
"type": "node",
"request": "attach",
"name": "proxy2",
"address": "0.0.0.0",
"port": 9091,
"localRoot": "${workspaceFolder}/proxy2/src",
"remoteRoot": "/proxy2/src",
"skipFiles": [
"<node_internals>/**"
],
},
{
"type": "node",
"request": "attach",
"name": "proxy1",
"address": "0.0.0.0",
"port": 9092,
"localRoot": "${workspaceFolder}/proxy1/src",
"remoteRoot": "/proxy1/src",
"skipFiles": [
"<node_internals>/**"
],
}
]
}
I would like to debug all the 3 services one by one, starting from main-service through code vscode (preferably) or at least through chrome://inspect.
What I am missing here?