-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add VS Code debug configuration (#48)
* Add vscode debug config for flask app Adds a docker-compose.debug.yml file based on the existing docker-compose.yml file used in dev, which overrides the default command in order to install debugpy and wait for a debugger to attach via port 6789 prior to running the flask dev server process. * Add vscode debug config for save_routes.py Adds configuration for debugging the `save_routes.py` script using the flask-dev Docker image. This configuration can be used as prior art for adding other script debug configuration in the future, or adjusted to accept a user-specified command to run rather than creating vscode tasks for each script. Note: a prompt was added to allow M1/M2 Mac users to select a working platform; this will ideally be removed in the future as support for ARM64 wheels is added to installed packages, but is necessary for now to successfully build the Docker image. * Add docs for new debug configuration * Update compose debug config to be used as extension to base compose config Updates the `docker-compose.debug.yml` config to define only settings that should override or extend the base `docker-compose.yml` config.
- Loading branch information
1 parent
d7f6092
commit aff38ae
Showing
5 changed files
with
115 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
// 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": "Python: Attach", | ||
"type": "python", | ||
"request": "attach", | ||
"connect": { | ||
"host": "localhost", | ||
"port": 6789 | ||
}, | ||
"pathMappings": [ | ||
{ | ||
"localRoot": "${workspaceFolder}/backend", | ||
"remoteRoot": "/app/backend" | ||
} | ||
], | ||
|
||
}, | ||
{ | ||
"name": "Docker: flask-dev - save_routes.py", | ||
"type": "docker", | ||
"request": "launch", | ||
"preLaunchTask": "docker-run: save_routes.py", | ||
"python": { | ||
"pathMappings": [ | ||
{ | ||
"localRoot": "${workspaceFolder}/backend", | ||
"remoteRoot": "/app/backend" | ||
} | ||
], | ||
"projectType": "general" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"type": "docker-build", | ||
"label": "docker-build", | ||
"platform": "python", | ||
"dockerBuild": { | ||
"tag": "opentransitmetrics:flask-dev", | ||
"dockerfile": "${workspaceFolder}/Dockerfile", | ||
"context": "${workspaceFolder}", | ||
"pull": true, | ||
"target": "flask-dev", | ||
"customOptions": "${input:dockerBuildm1}", | ||
} | ||
}, | ||
{ | ||
"type": "docker-run", | ||
"label": "docker-run: save_routes.py", | ||
"dependsOn": [ | ||
"docker-build" | ||
], | ||
"python": { | ||
"args": ["--s3", "--timetables", "--scheduled-stats", "--agency=trimet"], | ||
"file": "save_routes.py" | ||
} | ||
} | ||
], | ||
"inputs": [ | ||
{ | ||
"id": "dockerBuildm1", | ||
"type": "pickString", | ||
"description": "Select '--platform linux/amd64' to build for Macs with an ARM CPU", | ||
"default": "", | ||
"options": [ | ||
"--platform linux/amd64", | ||
"" | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# | ||
# docker-compose file configured for starting the flask-dev service | ||
# with debug config for use with VS Code. | ||
# Should be started up as follows: | ||
# - Run `docker compose up` with the `docker-compose.yml` file as the base config. | ||
# For example: `docker compose -f "docker-compose.yml" -f "docker-compose.debug.yml" up --build` | ||
# - Once the flask-dev service has started, attach the VS Code debugger by switching | ||
# to the debug sidebar and running the `Python: Attach` config. | ||
# - Add breakpoints as desired to flask app code. | ||
version: "3.7" | ||
services: | ||
flask-dev: | ||
command: ["sh", "-c", "pip install debugpy -t /tmp && python /tmp/debugpy --wait-for-client --listen 0.0.0.0:6789 -m flask run --no-debugger --no-reload --host 0.0.0.0 --port 5000"] | ||
ports: | ||
- "6789:6789" |