Skip to content

Commit

Permalink
Template application deploy #8694536012
Browse files Browse the repository at this point in the history
  • Loading branch information
nava-platform-bot committed Apr 15, 2024
1 parent e336430 commit d099742
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .template-flask-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
b34be60dcecef56be1e4340de6a990fe4dea4cd5
5730b467c35b6aa796706e325505f06eaeef935a
3 changes: 3 additions & 0 deletions app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ build:
start:
docker compose up --detach

start-debug:
docker compose -f ../docker-compose.yml -f ../docker-compose.debug.yml up --detach

run-logs: start
docker compose logs --follow --no-color $(APP_NAME)

Expand Down
57 changes: 54 additions & 3 deletions app/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ pytest-watch = "^4.2.0"
pytest-lazy-fixture = "^0.6.3"
types-pyyaml = "^6.0.12.11"
setuptools = "^68.2.2"
debugpy = "^1.8.1"

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand Down
51 changes: 50 additions & 1 deletion docs/app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ root
│ └── src
│ └── auth Authentication code for API
│ └── db
│ └── models DB model definitions
│ └── models DB model definitions
│ └── migrations DB migration configs
│ └── versions The DB migrations
│ └── logging
Expand Down Expand Up @@ -105,3 +105,52 @@ Any environment variables specified directly in the [docker-compose](/docker-com
## Authentication

This API uses a very simple [ApiKey authentication approach](https://apiflask.com/authentication/#use-external-authentication-library) which requires the caller to provide a static key. This is specified with the `API_AUTH_TOKEN` environment variable.

## VSCode Remote Attach Container Debugging

The API can be run in debug mode that allows for remote attach debugging (currently only supported from VSCode) to the container.

- Requirements:

- VSCode Python extension
- Updated Poetry with the `debugpy` dev package in `pyproject.toml`

- First create a file `./vscode/launch.json` - as shown below. (Default name of `Python: Remote Attach`)

- Start the server in debug mode via `make start-debug` or `make start-debug run-logs`.
- This will start the `main-app` service with port 5678 exposed.

- The server will start in waiting mode, waiting for you to attach the debugger (see `/src/app.py`) before continuing to run.

- Go to your VSCode debugger window and run the `Python: Remote Attach` option

- You should now be able to hit set breakpoints throughout the API

`./vscode/launch.json`:

```
{
// 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: Remote Attach",
"type": "debugpy",
"request": "attach",
"connect": {
"host": "localhost",
"port": 5678
},
"pathMappings": [
{
"localRoot": "${workspaceFolder}/app",
"remoteRoot": "."
}
],
"justMyCode": false,
}
]
}
```

0 comments on commit d099742

Please sign in to comment.