[英]WebStorm 2018.1: I am not able to hit breakpoints running remote debugging typescript from docker container
I am using the docker integration tool to run docker-compose to start two containers, one for node and one for mongodb. 我使用docker集成工具运行docker-compose来启动两个容器,一个用于节点,一个用于mongodb。
Here is the docker-compose.yml file: 这是docker-compose.yml文件:
version: '2.1'
services:
mongo:
container_name: "app_mongo"
hostname: "mongo"
tty: true
image: mongo:latest
environment:
- MONGO_DATA_DIR=/data/db
- MONGO_LOG_DIR=/dev/null
- MONGO_INITDB_DATABASE=***********
- MONGO_INITDB_ROOT_USERNAME=************
- MONGO_INITDB_ROOT_PASSWORD=********************
volumes:
- /data/db:/data/db
ports:
- 27017:27017
command: "mongod --smallfiles --auth"
networks:
- my-app-network
group:
container_name: "app_api1"
hostname: "api1"
build:
context: .
dockerfile: api1.dev.yml
entrypoint: ["npm", "run", "debug"]
volumes:
- ".:/home/app"
ports:
- 3000:3000
- 56745:56745
depends_on:
- "mongo"
networks:
- my-app-network
networks:
my-app-network:
driver: bridge
Here is the api1.dev.yml file: 这是api1.dev.yml文件:
FROM node:latest
ADD package.json /tmp/package.json
RUN cd /tmp && npm install --production && npm install -g nodemon
RUN mkdir -p /home/app && cp -a /tmp/node_modules /home/app/ && mkdir -p /home/app/dist
ADD package.json /home/app/package.json
ADD .env /home/app/.env
WORKDIR /home/app
Here is the script entry in package.json: 这是package.json中的脚本条目:
"scripts": {
"debug": "nodemon --inspect=56745 --require ts-node/register app/app.ts"
// "debug": "nodemon -L --inspect=56745 dist/myapp/app.js"
}
I also added a new "Attach to Node.js/Chrome" item to attach to the debugging port for node. 我还添加了一个新的“附加到Node.js / Chrome”项目以附加到节点的调试端口。
I run the docker-compose file followed by debugging the "Attach to Node.js/Chrome" item after node is up and listening. 我运行docker-compose文件,然后在节点启动和监听后调试“Attach to Node.js / Chrome”项。
When I try to hit a breakpoint in a .ts file, nothing is happening. 当我尝试在.ts文件中点击断点时,什么也没发生。 I am seeing the endpoint is called. 我看到端点被调用。
What are the steps involved in debugging a typescript app from docker and what am I doing wrong? 从docker调试打字稿应用程序涉及的步骤是什么?我做错了什么?
Where can I find a good tutorial that walks through how to debug typecript for a node.js app hosted inside of a docker container? 我在哪里可以找到一个很好的教程,介绍如何为docker容器中托管的node.js应用程序调试类型操作?
An answer was finally provided to me. 最后给了我答案。 Ultimately, I had to change the debug script from "debug": "nodemon -L --inspect=56745 dist/myapp/app.js" to "nodemon -L --inspect=0.0.0.0:56745 dist/myapp/app.js". 最终,我不得不将调试脚本从“debug”更改为:“nodemon -L --inspect = 56745 dist / myapp / app.js”改为“nodemon -L --inspect = 0.0.0.0:56745 dist / myapp / app” .js文件”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.