Skip to content

Commit ebfb89a

Browse files
authored
Adapt devcontainer.json for systemd-based devcontainer image (#131)
* Adapt devcontainer.json for systemd-based devcontainer image Update devcontainer.json settings to work with the new systemd-based devcontainer image (v4). - Update name to mention apps instead of add-ons - Use same order of elements as in devcontainer template - Bump image tag to 4-supervisor to get the systemd-enabled image - Set overrideCommand to false so the image's CMD (/sbin/init) runs as PID 1 instead of being replaced by VS Code's default sleep command - Set remoteUser to vscode to preserve the non-root shell experience (required when overrideCommand is false, since VS Code no longer injects its own user-switching wrapper) - Add /var/lib/containerd volume mount because modern Docker uses the containerd snapshotter, which stores layer data outside /var/lib/docker - Add tmpfs on /tmp to match typical systemd expectations and avoid leftover state across container restarts * Use apps command instead of deprecated addons command in tasks.json * Add install app command to tasks.json * Use ha apps command for log captureing
1 parent b09b6e5 commit ebfb89a

2 files changed

Lines changed: 29 additions & 11 deletions

File tree

.devcontainer.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
{
2-
"name": "Example devcontainer for add-on repositories",
3-
"image": "ghcr.io/home-assistant/devcontainer:2-addons",
2+
"name": "Example devcontainer for apps repositories",
3+
"image": "ghcr.io/home-assistant/devcontainer:4-apps",
4+
"overrideCommand": false,
5+
"remoteUser": "vscode",
46
"appPort": ["7123:8123", "7357:4357"],
57
"postStartCommand": "bash devcontainer_bootstrap",
68
"runArgs": ["-e", "GIT_EDITOR=code --wait", "--privileged"],
9+
"workspaceFolder": "/mnt/supervisor/addons/local/${localWorkspaceFolderBasename}",
10+
"workspaceMount": "source=${localWorkspaceFolder},target=${containerWorkspaceFolder},type=bind,consistency=cached",
711
"containerEnv": {
812
"WORKSPACE_DIRECTORY": "${containerWorkspaceFolder}"
913
},
10-
"workspaceFolder": "/mnt/supervisor/addons/local/${localWorkspaceFolderBasename}",
11-
"workspaceMount": "source=${localWorkspaceFolder},target=${containerWorkspaceFolder},type=bind,consistency=cached",
1214
"customizations": {
1315
"vscode": {
1416
"extensions": ["timonwong.shellcheck", "esbenp.prettier-vscode"],
@@ -28,6 +30,8 @@
2830
},
2931
"mounts": [
3032
"type=volume,target=/var/lib/docker",
31-
"type=volume,target=/mnt/supervisor"
33+
"type=volume,target=/var/lib/containerd",
34+
"type=volume,target=/mnt/supervisor",
35+
"type=tmpfs,target=/tmp"
3236
]
3337
}

.vscode/tasks.json

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,23 @@
1616
"problemMatcher": []
1717
},
1818
{
19-
"label": "Start Addon",
19+
"label": "Install App",
2020
"type": "shell",
21-
"command": "ha addons stop \"local_${input:addonName}\"; ha addons start \"local_${input:addonName}\"; docker logs --follow \"addon_local_${input:addonName}\"",
21+
"command": "ha apps install \"local_${input:appName}\"",
22+
"group": {
23+
"kind": "test",
24+
"isDefault": false
25+
},
26+
"presentation": {
27+
"reveal": "always",
28+
"panel": "new"
29+
},
30+
"problemMatcher": []
31+
},
32+
{
33+
"label": "Start App",
34+
"type": "shell",
35+
"command": "ha apps stop \"local_${input:appName}\"; ha apps start \"local_${input:appName}\"; ha apps logs -f \"local_${input:appName}\"",
2236
"group": {
2337
"kind": "test",
2438
"isDefault": false
@@ -33,9 +47,9 @@
3347
}
3448
},
3549
{
36-
"label": "Rebuild and Start Addon",
50+
"label": "Rebuild and Start App",
3751
"type": "shell",
38-
"command": "ha addons rebuild --force \"local_${input:addonName}\"; ha addons start \"local_${input:addonName}\"; docker logs --follow \"addon_local_${input:addonName}\"",
52+
"command": "ha apps rebuild --force \"local_${input:appName}\"; ha apps start \"local_${input:appName}\"; ha apps logs -f \"local_${input:appName}\"",
3953
"group": {
4054
"kind": "test",
4155
"isDefault": false
@@ -49,9 +63,9 @@
4963
],
5064
"inputs": [
5165
{
52-
"id": "addonName",
66+
"id": "appName",
5367
"type": "pickString",
54-
"description": "Name of addon (to add your addon to this list, please edit .vscode/tasks.json)",
68+
"description": "Name of app (to add your app to this list, please edit .vscode/tasks.json)",
5569
"options": [
5670
"example",
5771
]

0 commit comments

Comments
 (0)