Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for rebuilding the edge/dev container #1

Open
jhansche opened this issue May 16, 2023 · 6 comments
Open

Support for rebuilding the edge/dev container #1

jhansche opened this issue May 16, 2023 · 6 comments

Comments

@jhansche
Copy link

I'm not entirely sure how the process works for add-ons, but I know that the ESPHome (dev) add-on has a "Rebuild" button that will cause it to rebuild the docker image from the latest dev branch.

When we install the dev add-on from this repo, it installs a statically named "dev" image, and then never gives an option to update it or rebuild it. As far as I can tell, the only way to get a newer version is to uninstall and reinstall (but maybe I'm mistaken?)

Some information (about 2/3 down the article.. I tried to link to the section, but the link-to-highlight seems to get removed randomly by LinkedIn) I've found online seems to indicate that the Rebuild button is shown when the config.json does not contain an image field, which your dev repo does: https://github.com/mrlt8/edge-repo/blob/main/dev/config.json

For comparison, esphome-beta contains an image field: https://github.com/esphome/home-assistant-addon/blob/main/esphome-beta/config.yaml#L38
while esphome-dev does not: https://github.com/esphome/home-assistant-addon/blob/main/esphome-dev/config.yaml
Also esphome-dev contains a build.yaml to describe how to do the rebuild: https://github.com/esphome/home-assistant-addon/blob/main/esphome-dev/build.yaml

It took me a long time to realize that my add-on was out of date (v2.0.1 while v2.1.5 was available), because Home Assistant did not offer to update it since version "dev" == "dev". I was using the dev build to test out some earlier changes you made for testing the Wyze Cam OG, and then never switched back to the main add-on image. I've since uninstalled the dev add-on and reinstalled the main one, so at least now I'll get update notifications again.

@jhansche
Copy link
Author

Here are examples of the Add-On screens for the wyze docker bridge (dev) add-on
Screenshot 2023-05-16 at 6 30 40 PM
compared to the esphome-dev add-on:
Screenshot 2023-05-16 at 6 30 25 PM

@mrlt8
Copy link
Owner

mrlt8 commented May 17, 2023

I'm pretty sure you only get the rebuild button if you have the source files for the add-on locally, so you'd need to clone the main repo to your HA addons directory and update the config.json to comment out the image (I have the rebuild option on may local dev HA).

Not sure how ESPHome is able to pull the updates for the build, but this repo is mostly meant to test the dev images before they get pushed they get merged into the versioned release since HA doesn't have an option to pull specific images by tag.

@jhansche
Copy link
Author

Bumping this again, as I ran into again trying to test the latest dev image, only to find that the add-on simply wouldn't start anymore.

I don't know anything about HA add-on development, or how the ESPHome add-ons work. But I do know that I get regular updates on both the ESPHome and ESPHome (beta) add-ons, and I have the option to Rebuild the ESPHome (dev) add-on. Looking at the ESPHome repo again, the differences appear to be:

  1. config.json does contains image in the production add-on, but not in dev
  2. build.yaml exists for the dev version, and not the others
  3. Dockerfile exists for the dev version, and not the others

So maybe that's what you meant by requiring that the add-on sources be available locally? But I know I definitely did not do anything special to be able to get the ESPHome (dev) add-on installed - it is installed straight from the add-on store, and I still get the Rebuild option. I can try asking in Discord (ESPHome or HA) to see if anyone more familiar with building add-ons has any pointers.

@jhansche
Copy link
Author

jhansche commented Jul 22, 2023

Looking into this again, it kind of seems like all the Rebuild button does (or should do) is rebuild the docker container, not rebuild the image.

https://hub.docker.com/r/esphome/esphome-hassio/tags
https://hub.docker.com/r/mrlt8/wyze-bridge/tags

Since the image is what you build from https://github.com/mrlt8/docker-wyze-bridge sources and upload yourself to docker hub, we don't need it to rebuild the image from sources - all we need to do is tell supervisor to rebuild the container, using the latest tagged image from docker hub, which is what this build.yaml file tells it how to do for esphome:
https://github.com/esphome/home-assistant-addon/blob/main/esphome-dev/build.yaml

Maybe it's enough to just list the build-from images, to make this work?

The production add-on gets updates automatically, because the version field changes. But because the dev image is intentionally unversioned, that is never seen as an update in HA. But rebuilding the container from the latest tagged image should be enough.

That said, I don't know if build.yaml also requires a Dockerfile 🤷‍♂️ But maybe the Dockerfile can be simpler in this case, because you already have a source image.

Again, not very familiar with building Docker containers, or add-ons, so this is just speculation.

@mrlt8
Copy link
Owner

mrlt8 commented Jul 25, 2023

Thanks for the suggestions @jhansche! I think I was able to get this to work. The key was to source the existing image in the local Dockerfile so that HA thinks it can build the image but is actually just pulling the prebuilt image.

@jhansche
Copy link
Author

I saw a message in discord referencing a PR, fixing a bug where Supervisor would sometimes try to actually rebuild the image, which was never the intention. The purpose of the rebuild button is to rebuild the container, not the image. So I think what you're describing is how it's supposed to work 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants