Skip to content

Commit

Permalink
feat: enable debugging server running in container with vscode, #70
Browse files Browse the repository at this point in the history
  • Loading branch information
weaponsforge committed Oct 3, 2024
1 parent 99d7fb3 commit 36b0220
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 4 deletions.
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ todo-next is a regular TO-DO notes listing app aimed for testing using NextJS an
- [Seed MongoDB with Default Data](#seed-mongodb-with-default-data)
- [Docker Commands](#docker-commands)
- [Deployment With GitHub Actions](#deployment-with-gitHub-actions)
- [Other Notes](#other-notes)

## Installation

Expand Down Expand Up @@ -174,6 +175,40 @@ This project deploys the production live demo to GitHub Pages (front end) and Ve
| --- | --- |
| DOCKERHUB_USERNAME | (Optional) Docker Hub username. Required to enable pushing the development image to Docker Hub. |

## Other Notes

<details>
<summary>
<b>Debugging the server app running inside a container with VSCode</b>
</summary>

1. Add the following configuration in the VSCode `launch.json` file's `"configuration": []` array. <br>
```
{
"type": "node",
"request": "attach",
"name": "Docker: Attach to Node",
"port": 9229,
"address": "localhost",
"localRoot": "${workspaceFolder}//server",
"remoteRoot": "/opt/server",
"restart": true,
"sourceMaps": true,
"skipFiles": ["<node_internals>/**"]
}
```

2. Run the server container.

3. To enable debugging the server running inside the container from **step # 2** with VSCode:
- Press Ctrl + Shift + D
- Select `"Docker: Attach to Node"`
- Press the **Play** button (green arrow icon)

</details>

<br><br>

@weaponsforge<br>
20220820<br>
20241004
4 changes: 3 additions & 1 deletion docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ services:
networks:
- todo-next-dev
volumes:
- ./server/src:/opt/server/src
- ./server:/opt/server
- /opt/server/node_modules
ports:
- "3001:3001"
- "9229:9229"
depends_on:
- mongo
links:
Expand Down
3 changes: 3 additions & 0 deletions server/.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ Dockerfile
.dockerignore
.env
.vercel
*.zip
*.rar
*.txt
5 changes: 3 additions & 2 deletions server/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
node_modules/
.env
*.zip

.vercel
*.rar
*.txt
.vercel
2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"start": "node api/index.js",
"start:vercel": "node api/index.js",
"dev": "nodemon watch src/index.js",
"dev": "nodemon --inspect=0.0.0.0:9229 src/index.js",
"lint": "eslint src",
"lint:fix": "eslint src --fix"
},
Expand Down

0 comments on commit 36b0220

Please sign in to comment.