Skip to content

Commit 62292e3

Browse files
authored
Fix addon devcontainer not being able to build addons (#135)
* Fix addon devcontainer not being able to build addons * Refactor workspaceMount in devcontainer.json
1 parent e8e2c34 commit 62292e3

3 files changed

Lines changed: 11 additions & 2 deletions

File tree

addons/devcontainer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
"appPort": ["7123:8123", "7357:4357"],
55
"postStartCommand": "bash devcontainer_bootstrap",
66
"runArgs": ["-e", "GIT_EDITOR=code --wait", "--privileged"],
7+
"workspaceFolder": "/mnt/supervisor/addons/local/${localWorkspaceFolderBasename}",
8+
"workspaceMount": "source=${localWorkspaceFolder},target=${containerWorkspaceFolder},type=bind,consistency=cached",
79
"containerEnv": {
810
"WORKSPACE_DIRECTORY": "${containerWorkspaceFolder}"
911
},

addons/rootfs/usr/bin/devcontainer_bootstrap

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,12 @@ set -e
44

55
bash /usr/bin/supervisor_bootstrap
66

7-
exit 0
7+
workspace_mount="/mnt/supervisor/addons/local/$(basename "${WORKSPACE_DIRECTORY:?}")"
8+
if ! mountpoint -q "${workspace_mount}"; then
9+
echo "WARNING: Mounting ${WORKSPACE_DIRECTORY} to ${workspace_mount}." >&2
10+
echo "To avoid this warning, see https://github.com/home-assistant/devcontainer/pull/135." >&2
11+
sudo mkdir -p "${workspace_mount}"
12+
sudo mount --bind "${WORKSPACE_DIRECTORY}" "${workspace_mount}"
13+
fi
14+
15+
exit 0

addons/rootfs/usr/bin/supervisor_run

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ function run_supervisor() {
2222
-v /run/dbus:/run/dbus:ro \
2323
-v /run/udev:/run/udev:ro \
2424
-v /mnt/supervisor:/data:rw \
25-
-v "$WORKSPACE_DIRECTORY":/data/addons/local:rw \
2625
-v /etc/machine-id:/etc/machine-id:ro \
2726
-e SUPERVISOR_SHARE="/mnt/supervisor" \
2827
-e SUPERVISOR_NAME=hassio_supervisor \

0 commit comments

Comments
 (0)