Bluefin - Using distrobox with vscode tasks

Bluefin - Using distrobox with vscode tasks

I have performed 4 experiments thus far, and this one supplied unexpected glee.

Sometimes you just need to get things done. So reach into your toolbox and voila!

Problem Statement

As a developer using one of the bluefin-dx bootc images, I would like:

  • Given a VS Code project that needs multiple processes to start testing
  • One of the processes can run on the host given what I have installed with brew or installed into my $HOME dir
  • But one of the processes needs to run in a distrobox running on my host

I really should define a devcontainer, but …

Approach

Given the context described above I opted to construct a compound vscode task.

One of the tasks just executes with what I have on the host.

The other task uses distrobox enter box-name -- command to execute on my running distrobox.

But the first task ties them both together for the DX for which I was looking.

Expand to see sample .vscode/tasks.json
{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Full Stack",
            "dependsOn": [
                "Tailwind Dev Server",
                "Django Dev Server",
            ]
        },
        {
            "label": "Tailwind Dev Server",
            "type": "shell",
            "command": "distrobox",
            "args": [
                "enter",
                "fedora41-python-dx",
                "--",
                "pnpm",
                "run",
                "dev"
            ],
            "options": {
                "cwd": "${workspaceFolder}"
            }
        },
        {
            "label": "Django Dev Server",
            "type": "shell",
            "command": "pdm",
            "args": [
                "manage",
                "runserver"
            ],
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "problemMatcher": [
                "$python"
            ]
        }
    ]
}

Use the Command Palette command Tasks: Run Task and select Full Stack (first item in the .vscode/tasks.json file) from the drop down to launch all processes to start developing.

This will run pnpm run dev in the fedora41-python-dx distrobox, and pdm manage runserver on the host. They will start in separate vscode terminal processes.

Enjoy!

References

  1. Integrate with External Tools via Tasks
  2. Bluefin - rely on OCI layer sharing for distrobox and devcontainer
  3. GitHub - klmcwhirter/oci-shared-images: Bluefin - rely on OCI layer sharing for distrobox and devcontainer