Skip to content

Comments

Fix addon devcontainer not being able to build addons#135

Merged
agners merged 2 commits intohome-assistant:mainfrom
felipecrs:fix-not-building-with-buildkit
Jul 7, 2025
Merged

Fix addon devcontainer not being able to build addons#135
agners merged 2 commits intohome-assistant:mainfrom
felipecrs:fix-not-building-with-buildkit

Conversation

@felipecrs
Copy link
Contributor

@felipecrs felipecrs commented Jul 7, 2025

Coming from the warning?

If you came here because of a warning like this:

image

Then all you need to do is add these two lines to your devcontainer.json:

  "workspaceFolder": "/mnt/supervisor/addons/local/${localWorkspaceFolderBasename}",
  "workspaceMount": "source=${localWorkspaceFolder},target=${containerWorkspaceFolder},type=bind,consistency=cached",

PR description

After home-assistant/supervisor#5974 was merged, the add-on devcontainer was not able to build addons.

Now that Supervisor delegates the build to a container, we need to ensure that the add-on directory is within Supervisor's data directory on the host, so that Supervisor can properly mount it within the builder container.

Note that this PR is backwards compatible, i.e. it will work even against Supervisor versions prior to home-assistant/supervisor#5974.

I tested this and confirmed it works.

Closes home-assistant/supervisor#5991

/cc @agners

@felipecrs felipecrs force-pushed the fix-not-building-with-buildkit branch from be04aa4 to 9c23b02 Compare July 7, 2025 00:59
@ggravlingen
Copy link

@felipecrs is it possible to take this for a spin while waiting for the PR to be reviewed and merged?

@felipecrs
Copy link
Contributor Author

@felipecrs is it possible to take this for a spin while waiting for the PR to be reviewed and merged?

Yes, swap your devcontainer image with ghcr.io/felipecrs/homeassistant-addons-devcontainer.

@ggravlingen
Copy link

@felipecrs is it possible to take this for a spin while waiting for the PR to be reviewed and merged?

Yes, swap your devcontainer image with ghcr.io/felipecrs/homeassistant-addons-devcontainer.

Thank you! Can confirm it works on my Apple M2.

2025-07-07 18:27:34.721 INFO (MainThread) [supervisor.docker.addon] Starting build for local/amd64-addon-pypmanager-hass:1.0.0
2025-07-07 18:27:34.725 INFO (SyncWorker_3) [supervisor.docker.manager] Runing command '['docker', 'buildx', 'build', '.', '--tag', 'local/amd64-addon-pypmanager-hass:1.0.0', '--file', 'Dockerfile', '--platform', 'linux/amd64', '--pull', '--label', 'io.hass.version=1.0.0', '--label', 'io.hass.arch=amd64', '--label', 'io.hass.type=addon', '--label', 'io.hass.name=Pypmanager', '--label', 'io.hass.description=Local portfolio management and transaction analysis tool', '--build-arg', 'BUILD_FROM=ghcr.io/home-assistant/amd64-base:latest', '--build-arg', 'BUILD_VERSION=1.0.0', '--build-arg', 'BUILD_ARCH=amd64']' on docker.io/library/docker:28.3.1-cli
2025-07-07 18:27:34.745 DEBUG (MainThread) [supervisor.hardware.monitor] Hardware monitor: remove - Device('/sys/fs/nfs/net/nfs_client')
2025-07-07 18:27:34.992 DEBUG (MainThread) [supervisor.hardware.monitor] Hardware monitor: add - Device('/sys/fs/nfs/net/nfs_client')
2025-07-07 18:27:36.542 DEBUG (MainThread) [supervisor.docker.addon] Build local/amd64-addon-pypmanager-hass:1.0.0 done: #0 building with "default" instance using docker driver

#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 201B 0.0s done
#1 WARN: InvalidDefaultArgInFrom: Default value for ARG $BUILD_FROM results in empty or invalid base image name (line 2)
#1 DONE 0.0s

#2 [internal] load metadata for ghcr.io/home-assistant/amd64-base:latest
#2 DONE 0.3s

#3 [internal] load .dockerignore
#3 transferring context: 2B done
#3 DONE 0.0s

#4 [1/1] FROM ghcr.io/home-assistant/amd64-base:latest@sha256:4bb7a73f643f07416573cb892396a76e2663bc7ac127d475f1f3a0b950a58e15
#4 CACHED

#5 exporting to image
#5 exporting layers done
#5 writing image sha256:ef2c98f95ae5021df423d1305edd9ac0bf41c34b1674ce0f97b1adf8676c2596 done
#5 naming to docker.io/local/amd64-addon-pypmanager-hass:1.0.0 done
#5 DONE 0.0s

 1 warning found (use docker --debug to expand):
 - InvalidDefaultArgInFrom: Default value for ARG $BUILD_FROM results in empty or invalid base image name (line 2)

2025-07-07 18:27:36.542 INFO (MainThread) [supervisor.docker.addon] Build local/amd64-addon-pypmanager-hass:1.0.0 done

@felipecrs felipecrs requested a review from agners July 7, 2025 18:19
Copy link
Member

@agners agners left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@agners agners merged commit 62292e3 into home-assistant:main Jul 7, 2025
3 checks passed
@felipecrs felipecrs deleted the fix-not-building-with-buildkit branch July 7, 2025 18:58
@dunxd
Copy link

dunxd commented Aug 31, 2025

I'm currently getting this when I try to install a local addon:
image

I have the lines mentioned above in my devcontainer.json

  "workspaceFolder": "/mnt/supervisor/addons/local/${localWorkspaceFolderBasename}",
  "workspaceMount": "source=${localWorkspaceFolder},target=${containerWorkspaceFolder},type=bind,consistency=cached",

What else is needed to get this devcontainer working again?

@felipecrs
Copy link
Contributor Author

felipecrs commented Aug 31, 2025

Yeah, I have been getting that in the
Supervisor devcontainer as well recently.

It's not related to this PR though.

@dunxd
Copy link

dunxd commented Sep 1, 2025

I can't see avenues to raising issues about the devcontainers. Issues isn't enabled on this repo. I'm not having much luck with discord. HA community just gets a few "me too" comments. How to get attention of people behind this part of HA?

@felipecrs
Copy link
Contributor Author

I'd open an issue in Supervisor repository, after all that devcontainer is borked too.

@felipecrs
Copy link
Contributor Author

@agners are issues intentionally disabled for this repository? Just checking, maybe it was just a miss.

@agners
Copy link
Member

agners commented Sep 8, 2025

@agners are issues intentionally disabled for this repository? Just checking, maybe it was just a miss.

I don't think so. I can't enable it, but I'll check with the team.

@agners
Copy link
Member

agners commented Sep 8, 2025

Speaking of this PR, should we maybe add these two lines to the template in this repository (addons/devcontainer.json)?

@felipecrs
Copy link
Contributor Author

@agners, but I did, right?

62292e3

@agners
Copy link
Member

agners commented Sep 8, 2025

@felipecrs uh right, I did not update my local devcontainer repo 🙈 . Sorry for the noise!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Addon build not working in devcontainer

4 participants