Skip to content

Commit

Permalink
Configure VS Code and debugpy for remote Docker debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
danniel committed Jul 17, 2024
1 parent f06adf1 commit b15696d
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 15 deletions.
19 changes: 19 additions & 0 deletions __vscode__launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"configurations": [
{
"name": "Attach (remote debug)",
"type": "debugpy",
"request": "attach",
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "/var/www/votong/"
}
],
"connect": {
"port": 5678,
"host": "127.0.0.1"
}
}
]
}
6 changes: 4 additions & 2 deletions backend/requirements-dev.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ werkzeug~=3.0.3
faker~=25.2.0

## make sure to sync these with the ../.pre-commit-config.yaml file
ruff==0.4.5
ruff==0.5.2
black==24.4.2

# utils
Expand All @@ -19,9 +19,11 @@ pip-tools~=7.4.1

# testing
pytest~=8.2.0

pytest-django~=4.8.0
pytest-xdist~=3.6.1
pytest-cov~=5.0.0

# debugging
debugpy~=1.8.2

-r requirements.txt
12 changes: 7 additions & 5 deletions backend/requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ black==24.4.2
# via -r requirements-dev.in
blessed==1.20.0
# via -r requirements.txt
boto3==1.34.142
boto3==1.34.144
# via
# -r requirements.txt
# django-ses
# pycognito
botocore==1.34.142
botocore==1.34.144
# via
# -r requirements.txt
# boto3
Expand All @@ -48,14 +48,16 @@ click==8.1.7
# via
# black
# pip-tools
coverage==7.5.4
coverage==7.6.0
# via pytest-cov
croniter==2.0.5
# via -r requirements.txt
cryptography==42.0.8
# via
# -r requirements.txt
# pyjwt
debugpy==1.8.2
# via -r requirements-dev.in
decorator==5.1.1
# via ipython
django==4.2.14
Expand All @@ -80,7 +82,7 @@ django-admin-autocomplete-filter==0.7.1
# via -r requirements.txt
django-admin-rangefilter==0.13.0
# via -r requirements.txt
django-allauth==0.63.3
django-allauth==0.63.6
# via -r requirements.txt
django-appconf==1.0.6
# via
Expand Down Expand Up @@ -258,7 +260,7 @@ requests==2.32.3
# requests-oauthlib
requests-oauthlib==2.0.0
# via -r requirements.txt
ruff==0.4.5
ruff==0.5.2
# via -r requirements-dev.in
s3transfer==0.10.2
# via
Expand Down
6 changes: 3 additions & 3 deletions backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ asgiref==3.8.1
# via django
blessed==1.20.0
# via -r requirements.in
boto3==1.34.142
boto3==1.34.144
# via
# -r requirements.in
# django-ses
# pycognito
botocore==1.34.142
botocore==1.34.144
# via
# boto3
# s3transfer
Expand Down Expand Up @@ -54,7 +54,7 @@ django-admin-autocomplete-filter==0.7.1
# via -r requirements.in
django-admin-rangefilter==0.13.0
# via -r requirements.in
django-allauth==0.63.3
django-allauth==0.63.6
# via -r requirements.in
django-appconf==1.0.6
# via django-avatar
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ services:
env_file:
- .env
environment:
ENVIRONMENT: "development"
ENVIRONMENT: "debug"
DATABASE_ENGINE: "postgresql"
DATABASE_HOST: "votong_db_dev"
DATABASE_PORT: "5432"
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ services:
- ./backend:/var/www/votong/backend
depends_on:
- db
ports:
- "5678:5678"

volumes:
votong_psql:
2 changes: 1 addition & 1 deletion docker/dockerfiles/Dockerfile.backend.dev
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ FROM python:${PYTHON_VERSION}-slim-bookworm

ENV PYTHONUNBUFFERED=1

ENV ENVIRONMENT ${ENVIRONMENT:-development}
ENV ENVIRONMENT ${ENVIRONMENT:-production}
ENV DEBUG ${DEBUG:-True}

ENV RUN_MIGRATIONS=True
Expand Down
12 changes: 9 additions & 3 deletions docker/s6-rc.d/backend/run
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ if [ "${ENVIRONMENT}" = "production" ]; then
--workers "${WORKERS}" \
--timeout 60
else
echo "Running in development mode"

python3 manage.py runserver 0.0.0.0:8000
if [ "${ENVIRONMENT}" = "development" ]; then
echo "Running in development mode"
python3 manage.py runserver 0.0.0.0:8000
else
echo "*********************************************"
echo "**** Running in development DEBUG mode ****"
echo "*********************************************"
python -Xfrozen_modules=off -m debugpy --wait-for-client --listen 0.0.0.0:5678 manage.py runserver 0.0.0.0:8000
fi
fi

0 comments on commit b15696d

Please sign in to comment.