提问人:secondubly 提问时间:10/3/2023 更新时间:10/3/2023 访问量:18
我究竟如何让 VS Code 调试与 docker compose 和 NodeJS 一起使用?
How exactly do I get VS Code debugging to work with docker compose and NodeJS?
问:
我一直在遵循 Microsoft 提供的 docker compose 指南和 VS Code。我已经成功地遵循了每个步骤,但是,由于某种原因,我似乎无法为我的docker compose配置进行VS Code调试。我可以让 docker compose 运行,但是当我附加到容器时,我似乎永远无法命中任何断点?当我运行我在我的 中设置的打字稿调试配置时,我可以命中断点并查看日志记录,所以我知道问题不在于 VS Code,所以一定是我做错了什么?难道因为我使用的是打字稿,我需要在生成的JS文件中设置调试点,而不是原来的打字稿?launch.json
我在下面附上了我的文件和文件,感谢您提供的任何帮助。launch.json
tasks.json
docker-compose.yml
launch.json文件
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Docker: Attach to Node",
"type": "node",
"request": "attach",
"preLaunchTask": "Compose Up (Dev)",
"postDebugTask": "Compose Down",
"localRoot": "{workspaceFolder}",
"remoteRoot": "/usr/src/app"
},
{
"type": "node",
"request": "launch",
"name": "Debug Typescript",
"skipFiles": ["<node_internals>/**"],
"program": "${workspaceFolder}/dist/bot.js",
"preLaunchTask": "tsc: build - src/tsconfig.json",
"envFile": "${workspaceFolder}/src/.env.development.local",
"outFiles": ["${workspaceFolder}/**/*.js"],
"resolveSourceMapLocations": ["${workspaceFolder}/**", "!**/node_modules/**"],
"console": "internalConsole"
},
]
}
tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "Compose Up (Dev)",
"type": "docker-compose",
"dockerCompose": {
"up": {
"detached": true,
"build": true,
"profiles": [
"dev"
]
},
"envFile": "${workspaceFolder}/src/.env.development",
"files": [
"${workspaceFolder}/docker-compose.yml"
]
}
},
{
"label": "Compose Down",
"type": "docker-compose",
"dockerCompose": {
"down": {
"removeVolumes": true,
"removeImages": "all"
}
}
}
]
}
docker-compose.yml
services:
prisma-studio:
container_name: prisma-studio
image: timothyjmiller/prisma-studio:latest
restart: unless-stopped
depends_on:
postgres:
condition: service_healthy
profiles:
- dev
environment:
POSTGRES_URL: ${DATABASE_URL}
ports:
- ${PRISMA_STUDIO_PORT}:${PRISMA_STUDIO_PORT}
postgres:
image: postgres:12.14
container_name: postgres
hostname: postgres
environment:
POSTGRES_USER: ${DB_USER}
POSTGRES_PASSWORD: ${DB_USER_PASS}
POSTGRES_DB: ${DB_NAME}
ports:
- ${DB_PORT}:${DB_PORT}
restart: 'unless-stopped'
volumes:
- 'postgres-data:/var/lib/postgresql/data'
healthcheck:
test: ["CMD-SHELL", "pg_isready -q -d $$POSTGRES_DB -U $$POSTGRES_USER"]
interval: 10s
timeout: 5s
retries: 5
futababot:
build: .
container_name: futababot
depends_on:
postgres:
condition: service_healthy
tty: true
env_file:
- src/.env.development
volumes:
postgres-data:
答: 暂无答案
评论