Help with devcontainers and docker compose

I have followed the instructions in Set up Development Environment | Home Assistant Developer Docs to see if I can debug an integration that is not working for me (tuya_ble).

When I first followed the instructions I was able to run and debug home assistant.

However, to test the integration properly, I need to somehow give the devcontainer access to my USB bluetooth dongle. To that end, I figure that I somehow need to incorporate docker compose to do that mapping of the USB device.

I have taken the core devcontainer.json from my cloned HA gitbhub repository and modified it as follows (removed the dockerfile property and replaced it with the dockerComposeFile, service and runServices properties.

{
	"name": "Home Assistant Dev",
	"context": "..",
	"service": "homeassistant",
	"runServices": "homeassistant",
	"dockerComposeFile": "docker-compose.yml",
	"postCreateCommand": "script/setup",
	"postStartCommand": "script/bootstrap",
	"containerEnv": { "DEVCONTAINER": "1" },
	"appPort": ["8123:8123"],
	"runArgs": ["-e", "GIT_EDITOR=code --wait"],
	"customizations": {
	  "vscode": {
		"extensions": [
		  "charliermarsh.ruff",
		  "ms-python.pylint",
		  "ms-python.vscode-pylance",
		  "visualstudioexptteam.vscodeintellicode",
		  "redhat.vscode-yaml",
		  "esbenp.prettier-vscode",
		  "GitHub.vscode-pull-request-github"
		],
		// Please keep this file in sync with settings in home-assistant/.vscode/settings.default.json
		"settings": {
		  "python.pythonPath": "/usr/local/bin/python",
		  "python.testing.pytestArgs": ["--no-cov"],
		  "editor.formatOnPaste": false,
		  "editor.formatOnSave": true,
		  "editor.formatOnType": true,
		  "files.trimTrailingWhitespace": true,
		  "terminal.integrated.profiles.linux": {
			"zsh": {
			  "path": "/usr/bin/zsh"
			}
		  },
		  "terminal.integrated.defaultProfile.linux": "zsh",
		  "yaml.customTags": [
			"!input scalar",
			"!secret scalar",
			"!include_dir_named scalar",
			"!include_dir_list scalar",
			"!include_dir_merge_list scalar",
			"!include_dir_merge_named scalar"
		  ],
		  "[python]": {
			"editor.defaultFormatter": "charliermarsh.ruff"
		  }
		}
	  }
	}
  }

Within the .devcontainer folder, I created a docker-compose.yml file as follows (note I haven’t even got as far as mapping the usb device /dev/bus/usb/001/008):

version: '3'
services:
  # Update this to the name of the service you want to work with in your docker-compose.yml file
  homeassistant:
    # Uncomment if you want to override the service's Dockerfile to one in the .devcontainer 
    # folder. Note that the path of the Dockerfile and context is relative to the *primary* 
    # docker-compose.yml file (the first in the devcontainer.json "dockerComposeFile"
    # array). The sample below assumes your primary file is in the root of your project.
    #
    build:
      dockerfile: ../Dockerfile.dev

But when I try to rebuild the container in VS code it spluts out the following

[2024-01-12T16:21:58.261Z] Start: Run: docker -v
[2024-01-12T16:21:58.291Z] Stop (30 ms): Run: docker -v
[2024-01-12T16:21:58.292Z] Start: Run: docker events --format {{json .}} --filter event=start
[2024-01-12T16:21:58.296Z] PersistedPath=/tmp/devcontainercli-root, ContainerHasLabels=false
[2024-01-12T16:21:58.298Z] Start: Run: docker compose -f /workspaces/home-assistant-core/.devcontainer/docker-compose.yml --profile * config
[2024-01-12T16:21:58.389Z] Stop (91 ms): Run: docker compose -f /workspaces/home-assistant-core/.devcontainer/docker-compose.yml --profile * config
[2024-01-12T16:21:58.390Z] name: devcontainer
services:
  homeassistant:
    build:
      context: /workspaces/home-assistant-core/.devcontainer
      dockerfile: ../Dockerfile.dev
    networks:
      default: null
networks:
  default:
    name: devcontainer_default
[2024-01-12T16:21:58.394Z] Start: Run: docker inspect --type image mcr.microsoft.com/vscode/devcontainers/python:0-3.11
[2024-01-12T16:21:58.422Z] Stop (28 ms): Run: docker inspect --type image mcr.microsoft.com/vscode/devcontainers/python:0-3.11
[2024-01-12T16:21:59.226Z] Docker Compose override file for building image:
version: '3'

services:
  homeassistant:
    build:
      dockerfile: /tmp/devcontainercli-root/container-features/0.54.1-1705076519206/Dockerfile-with-features
      args:
        - BUILDKIT_INLINE_CACHE=1
        - _DEV_CONTAINERS_BASE_IMAGE=dev_container_auto_added_stage_label

[2024-01-12T16:21:59.230Z] Start: Run: docker compose --project-name home-assistant-core_devcontainer -f /workspaces/home-assistant-core/.devcontainer/docker-compose.yml -f /tmp/devcontainercli-root/docker-compose/docker-compose.devcontainer.build-1705076519226.yml build h o m e a s s i s t a n t
[2024-01-12T16:21:59.339Z] no such service: h
[2024-01-12T16:21:59.343Z] Stop (113 ms): Run: docker compose --project-name home-assistant-core_devcontainer -f /workspaces/home-assistant-core/.devcontainer/docker-compose.yml -f /tmp/devcontainercli-root/docker-compose/docker-compose.devcontainer.build-1705076519226.yml build h o m e a s s i s t a n t
[2024-01-12T16:21:59.345Z] Error: Command failed: docker compose --project-name home-assistant-core_devcontainer -f /workspaces/home-assistant-core/.devcontainer/docker-compose.yml -f /tmp/devcontainercli-root/docker-compose/docker-compose.devcontainer.build-1705076519226.yml build h o m e a s s i s t a n t
[2024-01-12T16:21:59.346Z]     at pw (/root/.vscode-remote-containers/dist/dev-containers-cli-0.327.0/dist/spec-node/devContainersSpecCLI.js:427:522)
[2024-01-12T16:21:59.346Z]     at processTicksAndRejections (node:internal/process/task_queues:96:5)
[2024-01-12T16:21:59.346Z]     at async L$ (/root/.vscode-remote-containers/dist/dev-containers-cli-0.327.0/dist/spec-node/devContainersSpecCLI.js:427:2493)
[2024-01-12T16:21:59.346Z]     at async N$ (/root/.vscode-remote-containers/dist/dev-containers-cli-0.327.0/dist/spec-node/devContainersSpecCLI.js:409:3165)
[2024-01-12T16:21:59.346Z]     at async tAA (/root/.vscode-remote-containers/dist/dev-containers-cli-0.327.0/dist/spec-node/devContainersSpecCLI.js:479:3833)
[2024-01-12T16:21:59.346Z]     at async CC (/root/.vscode-remote-containers/dist/dev-containers-cli-0.327.0/dist/spec-node/devContainersSpecCLI.js:479:4775)
[2024-01-12T16:21:59.347Z]     at async NeA (/root/.vscode-remote-containers/dist/dev-containers-cli-0.327.0/dist/spec-node/devContainersSpecCLI.js:612:11107)
[2024-01-12T16:21:59.347Z]     at async MeA (/root/.vscode-remote-containers/dist/dev-containers-cli-0.327.0/dist/spec-node/devContainersSpecCLI.js:612:10848)
[2024-01-12T16:21:59.360Z] Stop (2086 ms): Run in container: node /root/.vscode-remote-containers/dist/dev-containers-cli-0.327.0/dist/spec-node/devContainersSpecCLI.js up --container-session-data-folder /tmp/devcontainers-26341e6a-630e-45e5-83d8-2fef149e541e1705076513022 --workspace-folder /workspaces/home-assistant-core --workspace-mount-consistency cached --id-label vsch.local.repository=https://github.com/mcclumpherty/home-assistant-core --id-label vsch.local.repository.volume=home-assistant-core-0f8cd95874c1e7bc1f0aeb45bb9eae9a505cf970b22efd42f5ea2cbe61a93f3d --id-label vsch.local.repository.folder=home-assistant-core --id-label devcontainer.config_file=/workspaces/home-assistant-core/.devcontainer/devcontainer.json --log-level debug --log-format json --config /workspaces/home-assistant-core/.devcontainer/devcontainer.json --default-user-env-probe loginInteractiveShell --remove-existing-container --mount type=volume,source=home-assistant-core-0f8cd95874c1e7bc1f0aeb45bb9eae9a505cf970b22efd42f5ea2cbe61a93f3d,target=/workspaces,external=true --mount type=volume,source=vscode,target=/vscode,external=true --skip-post-create --update-remote-user-uid-default off --mount-workspace-git-root
[2024-01-12T16:21:59.360Z] Exit code 1
[2024-01-12T16:21:59.361Z] Start: Run: docker rm -f c278ac5c5c7b2946a540551c3a6e3ebc3948347a79bde7d28890d0ab52a19b81
[2024-01-12T16:21:59.378Z] Command failed: node /root/.vscode-remote-containers/dist/dev-containers-cli-0.327.0/dist/spec-node/devContainersSpecCLI.js up --container-session-data-folder /tmp/devcontainers-26341e6a-630e-45e5-83d8-2fef149e541e1705076513022 --workspace-folder /workspaces/home-assistant-core --workspace-mount-consistency cached --id-label vsch.local.repository=https://github.com/mcclumpherty/home-assistant-core --id-label vsch.local.repository.volume=home-assistant-core-0f8cd95874c1e7bc1f0aeb45bb9eae9a505cf970b22efd42f5ea2cbe61a93f3d --id-label vsch.local.repository.folder=home-assistant-core --id-label devcontainer.config_file=/workspaces/home-assistant-core/.devcontainer/devcontainer.json --log-level debug --log-format json --config /workspaces/home-assistant-core/.devcontainer/devcontainer.json --default-user-env-probe loginInteractiveShell --remove-existing-container --mount type=volume,source=home-assistant-core-0f8cd95874c1e7bc1f0aeb45bb9eae9a505cf970b22efd42f5ea2cbe61a93f3d,target=/workspaces,external=true --mount type=volume,source=vscode,target=/vscode,external=true --skip-post-create --update-remote-user-uid-default off --mount-workspace-git-root
[2024-01-12T16:21:59.378Z] Exit code 1
[2024-01-12T16:21:59.416Z] Stop (4358 ms): Run in container: /bin/sh
[2024-01-12T16:21:59.417Z] Stop (4218 ms): Run in container: /bin/sh
[2024-01-12T16:21:59.418Z] Container server terminated (code: 137, signal: null).
[2024-01-12T16:21:59.628Z] Stop (267 ms): Run: docker rm -f c278ac5c5c7b2946a540551c3a6e3ebc3948347a79bde7d28890d0ab52a19b81
[2024-01-12T16:22:16.169Z] Start: Run: docker volume ls -q
[2024-01-12T16:22:16.201Z] Stop (32 ms): Run: docker volume ls -q
[2024-01-12T16:22:16.242Z] Start: Run: docker version --format {{.Server.APIVersion}}
[2024-01-12T16:22:16.290Z] Stop (48 ms): Run: docker version --format {{.Server.APIVersion}}
[2024-01-12T16:22:16.290Z] 1.43

I’m clearly doing something wrong here. Does anyone have an example of how to do this sort of thing?