Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: attaching with DEBUG=False #1160

Merged
merged 3 commits into from
Dec 7, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions docs/development/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,49 @@ inside a container.

If you do not receive a prompt, or when you feel like starting from a fresh environment:

1. `Ctrl/Cmd+Shift+P` to bring up the command palette in Visual Studio Code
1. <kbd>Ctrl</kbd>/<kbd>Cmd</kbd> + <kbd>Shift</kbd> + <kbd>P</kbd> to bring up the command palette in Visual Studio Code
1. Type `Remote-Containers` to filter the commands
1. Select `Rebuild and Reopen in Container` to completely rebuild the devcontainer
1. Select `Reopen in Container` to reopen the most recent devcontainer build

## Attach a debugger

Once running inside a container, press **`F5`** to attach a debugger to the client, running on `http://localhost` at a port
Once running inside a container, press <kbd>F5</kbd> to attach a debugger to the client, running on `http://localhost` at a port
dynamically assigned by Docker. See [Docker dynamic ports](./docker-dynamic-ports.md) for more information.

Add breakpoints in the code and browse the local site to trigger a pause. Press `F5` to continue execution from the breakpoint.
Add breakpoints in the code and browse the local site to trigger a pause. Press <kbd>F5</kbd> to continue execution from the breakpoint.

### Changing launch configuration

By default, the application is launched with `DJANGO_DEBUG=True`, causing Django to provide additional logging and error output and to relax certain security settings.

Alternatively, you may attach to an instance launched with `DJANGO_DEBUG=False`, to allow debugging the app in a state more similar to production.

In VS Code, press <kbd>Ctrl</kbd>/<kbd>Cmd</kbd> + <kbd>Shift</kbd> + <kbd>D</kbd> to open the `Run and Debug` pane, where you can select between the various configurations (disregard the duplicate entry, selecting either will work):

![Screenshot of the VSCode Run and Debug pane, showing selection of the launch configuration](img/vscode-debugger-launch-config.png)

The [environment](../configuration/environment-variables.md) can also be overridden for the debug session by editing the configuration in `.vscode/launch.json`, where any of the supported environment variables may be specified in the `env` block:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be extra explicit and search-friendly, add the example of For example, to test the app with reCAPTCHA environment variables... and then link to #1071

Otherwise LGTM 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in 0d0cd61


```json
{
"name": "Django: Benefits Client",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/manage.py",
"args": ["runserver", "--insecure", "0.0.0.0:8000"],
"django": true,
"env": {
"DJANGO_DEBUG": "true",
}
}
```

## Exiting devcontainers

To close out of the container and re-open the directory locally in Visual Studio Code:

1. `Ctrl/Cmd+Shift+P` to bring up the command palette in Visual Studio Code
1. <kbd>Ctrl</kbd>/<kbd>Cmd</kbd> + <kbd>Shift</kbd> + <kbd>P</kbd> to bring up the command palette in Visual Studio Code
1. Type `Remote-Containers` to filter the commands
1. Select `Reopen Locally`

Expand Down
2 changes: 1 addition & 1 deletion docs/development/docker-dynamic-ports.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Docker dynamically assigns host machine ports that map into container applicatio
Other services started along with the Devcontainer are not visible in VS Code. See
[Outside the Devconatiner](#outside-the-devcontainer) for how to find information on those.

Once started with `F5`, the `benefits` Django application runs on port `8000` inside the Devcontainer. To find the localhost
Once started with <kbd>F5</kbd>, the `benefits` Django application runs on port `8000` inside the Devcontainer. To find the localhost
address, look on the **PORTS** tab in VS Code's _Terminal_ window. The `Local Address` corresponding to the record where
`8000` is in the `Port` column is where the site is accessible on your host machine.

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.