BlueOS icon indicating copy to clipboard operation
BlueOS copied to clipboard

Add vscode launch file for remote debugging in the BlueOS container

Open Williangalvani opened this issue 6 months ago • 6 comments

You should see this when opening the Repo. install the extensions. image Ctrl+shift+p type ssh and pick Connect to Host image

Enter the pi's host and user

Screenshot 2025-08-05 at 12 13 36

Accept key and input password as needed.

The arrow button connects this vscode instance to the remote. the window button opens it in a new instance. Screenshot 2025-08-05 at 12 14 22 Wait as the server gets downloaded Screenshot 2025-08-05 at 12 15 13 Screenshot 2025-08-05 at 12 16 10 Switch to Dev containers once attached to the pi Screenshot 2025-08-05 at 12 16 50 attach to the container Screenshot 2025-08-05 at 12 17 27 Install python debugger extension on the container. Screenshot 2025-08-05 at 12 20 02

Open /home/pi as a workspace. That's where our service files live, and where the vscode debugger configuration is being saved.

Open any .py file, go to the debugger tab, use this task image

and start debugging =] Screenshot 2025-08-05 at 12 21 13

Notes:

  • The steps for installing the vscode server and debugging extension on the container will need to be done every time the container starts, as changes to the container are not permanent.
  • Make sure you BACKUP YOUR CHANGES! As the container is effemeral, your changes will be lost as soon as it restarts.

Summary by Sourcery

New Features:

  • Enable remote debugging in the BlueOS container via VS Code by adding a launch.json file and copying the .vscode directory into the container environment

Summary by Sourcery

Enable remote debugging of services in the BlueOS container by bundling VS Code launch settings and extension recommendations into the container image

New Features:

  • Add VS Code launch configuration for remote Python debugging inside the BlueOS container
  • Include recommended VS Code extensions in the container via extensions.json

Enhancements:

  • Update core Dockerfile to copy the .vscode directory into the /home/pi workspace

Williangalvani avatar Aug 05 '25 15:08 Williangalvani

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Automate VS Code remote debugging setup by embedding VS Code configuration into the BlueOS container image, including recommended extensions and a Python attach launch profile.

File-Level Changes

Change Details Files
Add VS Code configuration for remote debugging
  • Added project-wide VS Code extension recommendations
  • Added container-specific VS Code extension recommendations
  • Defined a Python remote attach launch profile
  • Configured Docker build to include the VS Code settings directory
.vscode/extensions.json
core/.vscode/extensions.json
core/.vscode/launch.json
core/Dockerfile

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an issue from a review comment by replying to it. You can also reply to a review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull request title to generate a title at any time. You can also comment @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in the pull request body to generate a PR summary at any time exactly where you want it. You can also comment @sourcery-ai summary on the pull request to (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the pull request to resolve all Sourcery comments. Useful if you've already addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull request to dismiss all existing Sourcery reviews. Especially useful if you want to start fresh with a new review - don't forget to comment @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

  • Contact our support team for questions or feedback.
  • Visit our documentation for detailed guides and information.
  • Keep in touch with the Sourcery team by following us on X/Twitter, LinkedIn or GitHub.

sourcery-ai[bot] avatar Aug 05 '25 15:08 sourcery-ai[bot]

Hey @Williangalvani - I've reviewed your changes - here's some feedback:

  • Use VS Code's devcontainer.json in a .devcontainer folder (rather than copying .vscode in the Dockerfile) to configure remote debugging without baking IDE settings into the image.
  • If you do need to copy .vscode, guard that step behind a build argument or separate dev-only stage so production images remain clean.

Prompt for AI Agents Sourcery is free for open source - if you like our reviews please consider sharing them ✨ Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

while that makes sense in theory, how would it work when I'm developing inside a container inside a remote host?

Williangalvani avatar Aug 05 '25 16:08 Williangalvani

LGTM, tested locally and it's working!

nicoschmdt avatar Aug 07 '25 14:08 nicoschmdt

@ES-Alexander can you turn my half-assed instructions into something usable? Pleeeeease?

Williangalvani avatar Aug 07 '25 15:08 Williangalvani

Hey @Williangalvani - I've reviewed your changes - here's some feedback:

  • In the Dockerfile, chown the .vscode directory to the pi user (e.g. RUN chown -R pi:pi /home/pi/.vscode) to avoid permission issues when debugging.

This is tested and working as is.

  • Rather than baking .vscode into the core image, consider using a devcontainer.json or docker-compose override for VS Code debugging to keep your production image clean.

it does look like devcontainer.json could be used here. I'll look into it

Williangalvani avatar Aug 12 '25 14:08 Williangalvani

it does look like devcontainer.json could be used here. I'll look into it

Nope, it looks like it can't do what we need.

Williangalvani avatar Aug 20 '25 15:08 Williangalvani