Skip to content

Commit 4efcb3a

Browse files
committed
add utilities and docs for debugging with docker
1 parent 348bb7f commit 4efcb3a

3 files changed

Lines changed: 40 additions & 1 deletion

File tree

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ COPY assets /usr/src/app/assets
2424

2525
ENV SETUPTOOLS_SCM_PRETEND_VERSION=99.99.99
2626
RUN uv pip install --system -e .[frontend]
27-
RUN uv pip install --system django-debug-toolbar
27+
RUN uv pip install --system django-debug-toolbar debugpy

compose.debug.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
services:
2+
app:
3+
ports:
4+
- 5678:5678
5+
command: >
6+
python -m debugpy --listen 0.0.0.0:5678 --wait-for-client
7+
manage.py runserver 0.0.0.0:8000 --noreload

docs/development.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,38 @@ A number of helpful development tools are made available through the `Makefile`,
2222

2323
**Important**: Please ensure all changes are included in `CHANGELOG.md` in a human-friendly format.
2424

25+
## Debugging with docker compose
26+
27+
To run using a debugger in e.g. vs code, run with the additional compose file `compose.debug.yml` which adds some additional settings to enable this.
28+
29+
Do so with: `docker compose -f compose.yml -f compose.debug.yml up`
30+
31+
This will launch the containers, but the `app` service will stop until a debugger is attached.
32+
33+
For VS Code, the launch config should look like:
34+
35+
```json
36+
{
37+
"version": "0.2.0",
38+
"configurations": [
39+
{
40+
"name": "Debug Dockerised Django",
41+
"type": "debugpy",
42+
"request": "attach",
43+
"pathMappings": [
44+
{
45+
"localRoot": "${workspaceFolder}",
46+
"remoteRoot": "/usr/src/app"
47+
}
48+
],
49+
"connect": {"host": "127.0.0.1", "port": 5678},
50+
}
51+
]
52+
}
53+
```
54+
55+
Run the debugger using this config to run the debugger listening to the debugging port configured.
56+
2557
## Release/Versioning
2658

2759
Version numbers should be used in tagging commits on the `main` branch and reflected in the `pyproject.toml` file and should be of the form `v0.1.7` using the semantic versioning convention.

0 commit comments

Comments
 (0)