Skip to content

Commit d9199ec

Browse files
committed
Try to get VS Code debugging working with Docker
1 parent 20dc4cc commit d9199ec

File tree

4 files changed

+94
-15
lines changed

4 files changed

+94
-15
lines changed

.dockerignore

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,37 @@
1-
**/.venv
2-
*console.log
3-
.coverage
4-
.env
5-
.idea/
6-
.mypy_cache/**/*
7-
.pytest_cache/**/*
8-
.ruff_cache/**/*
9-
db.sqlite
10-
docs_site/
11-
htmlcov
12-
latest.dump
13-
node_modules
14-
public/static/dist
1+
.coverage
2+
.idea/
3+
.mypy_cache/**/*
4+
.pytest_cache/**/*
5+
.ruff_cache/**/*
6+
**/__pycache__
7+
**/.classpath
8+
**/.dockerignore
9+
**/.env
10+
**/.git
11+
**/.gitignore
12+
**/.project
13+
**/.settings
14+
**/.toolstarget
15+
**/.venv
16+
**/.vs
17+
**/.vscode
18+
**/*.*proj.user
19+
**/*.dbmdl
20+
**/*.jfm
21+
**/bin
22+
**/charts
23+
**/compose*
24+
**/docker-compose*
25+
**/Dockerfile*
26+
**/node_modules
27+
**/npm-debug.log
28+
**/obj
29+
**/secrets.dev.yaml
30+
**/values.dev.yaml
31+
db.sqlite
32+
docs_site/
33+
htmlcov
34+
latest.dump
35+
LICENSE
36+
public/static/dist
37+
README.md

.vscode/launch.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Docker: Python - Django",
9+
"type": "docker",
10+
"request": "launch",
11+
"preLaunchTask": "docker-run: debug",
12+
"python": {
13+
"pathMappings": [
14+
{
15+
"localRoot": "${workspaceFolder}",
16+
"remoteRoot": "/srv/app"
17+
}
18+
],
19+
"projectType": "django"
20+
}
21+
}
22+
]
23+
}

.vscode/tasks.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"type": "docker-build",
6+
"label": "docker-build",
7+
"platform": "python",
8+
"dockerBuild": {
9+
"tag": "epicserve/django-base-site:latest",
10+
"dockerfile": "${workspaceFolder}/config/docker/Dockerfile.web",
11+
"context": "${workspaceFolder}",
12+
"pull": true
13+
}
14+
},
15+
{
16+
"type": "docker-run",
17+
"label": "docker-run: debug",
18+
"dependsOn": [
19+
"docker-build"
20+
],
21+
"python": {
22+
"args": [
23+
"runserver",
24+
"0.0.0.0:8000",
25+
"--nothreading",
26+
"--noreload"
27+
],
28+
"file": "manage.py"
29+
}
30+
}
31+
]
32+
}

docker-compose.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,14 @@ services:
2929
target: dev
3030
dockerfile: config/docker/Dockerfile.web
3131

32-
command: sh -c "./manage.py migrate --noinput && ./manage.py runserver 0.0.0.0:8000"
32+
command: ["sh", "-c", "./manage.py migrate --noinput && pip install debugpy -t /tmp && python /tmp/debugpy --wait-for-client --listen 0.0.0.0:5678 manage.py runserver 0.0.0.0:8000 --nothreading --noreload"]
3333

3434
volumes:
3535
- .:/srv/app:cached
3636

3737
ports:
3838
- "8000:8000"
39+
- "5678:5678"
3940

4041
depends_on:
4142
- node

0 commit comments

Comments
 (0)