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 "--platform" tag to prevent multi-arch FROM image architecture mismatch #131

Closed
alexbelgium opened this issue Jan 21, 2022 · 6 comments

Comments

@alexbelgium
Copy link

alexbelgium commented Jan 21, 2022

Hello,

I manage a repo with +/- 55 addons with local builds, and wanted to convert them to automatic builds. The github actions works very well and was easily implemented in my repo, thanks very much!

There is however one case of failure : addons builds succeed when building from multi-arch base images, but use a wrong arch which result in a "[FATAL tini (*)] exec // failed: Exec format error".

By looking at docker documentation, it seems the "--platform" tag is designed to avoid this.

“–platform” tag : The optional --platform flag can be used to specify the platform of the image in case FROM references a multi-platform image. For example, linux/amd64, linux/arm64, or windows/amd64. By default, the target platform of the build request is used. Global build arguments can be used in the value of this flag, for example automatic platform ARGs allow you to force a stage to native build platform (--platform=$BUILDPLATFORM), and use it to cross-compile to the target platform inside the stage. (Dockerfile reference | Docker Documentation)

I have tried to implement it in my build.json to reference a specific arch when pulling the image, but it fails due to REGEX validation.

Can't parse /data/addons/git/db21ed7f/addons_updater/build.json: does not match regular expression ^([a-zA-Z\-\.:\d{}]+/)*?([\-\w{}]+)/([\-\w{}]+)(:[\.\-\w{}]+)?$ for dictionary value @ data['build_from']['aarch64']. Got '--platform=linux/arm64 homeassistant/aarch64-base-python:3.9-alpine3.13'

Request : I believe that a solution would be to modify the REGEX to allow the plaform tag ; but a second solution could be to automatically support the "--platform" tag in the builder... It would make multi-arch source images work; and would make no impact on single-arch source images

Gain : this would greatly help to help additional users move from locally built to images-distributed addons.

Thanks very much for your consideration. Development is not my core expertise (and neither my full time work) so please bare with me if I was naive and misinterpreted the solution.

@frenck
Copy link
Member

frenck commented Jan 21, 2022

addons builds succeed when building from multi-arch base images

We don't publish multi-arch base images?

The problem with using multi-arch images, is that is will still go south in a bunch of cases. I would recommend not using a single image that contains multi-arch for that reason. I will lead to troubles (I've painfully learned that as well).

@alexbelgium
Copy link
Author

Thanks very much for your quick answer. To facilitate my addons updates, I usually base myself on pre-existing images from Dockerhub, then add through my Dockerfile the Bashio & Tempio scripts to allow more relevant HA scripts. This means the majority are not based on your excellent single-arch base images, but either on single-arch images from Linuxserver, or on multi-arch images from other providers...

Actually it seems to work great for local builds (I've tested on armv7, aarch64 & amd64), but the github action workflow script fails to provide the right arch.

I understand though that it is not an optimal way of working... Just the only one at my disposal as I've got a full time job and am maintaining my addons + supporting their on the side so I was trying to base my work on preexisting images as much as possible...

@frenck
Copy link
Member

frenck commented Jan 21, 2022

Actually it seems to work great for local builds (I've tested on armv7, aarch64 & amd64), but the github action workflow script fails to provide the right arch.

But will go south on armhf/armv6 for example.

@alexbelgium
Copy link
Author

alexbelgium commented Jan 21, 2022

Indeed, I've removed armhf from my builds... Well then thanks I'll close the issue then and keep as is :)

I take this opportunity of having your ear to say that I am a big fan of your work. Thanks so much for everything you've developed and your continued support.

BTW I know it's not good manners to ask another question in a same thread but as it will be closed soon :) how can we upgrade from locally build addons to image based addons? Even for my addons based on HA bas arch images, if I try to update in HA os a locally built addon (for example, a v 1.0 which has no image tag I pn it's config.json) with a new imaged-based version (for example if v2.0 that has the image tag in its config.json), the supervisor seems to still try to build locally according to its log. When the local build is completed, the addon however doesn't start and fails with an "image not found" with the name of the image in the config.json. My understanding is that the addon doesn't see at update that the new version is based on an image so it doesn't download it. When I uninstall completely the addon and reinstall It completely, it installs and runs fine showing that the issue with not with the image itself. Or am I missing something? Thanks again very much :)

@frenck
Copy link
Member

frenck commented Jan 21, 2022

I take this opportunity of having your ear to say that I am a big fan of your work. Thanks so much for everything you've developed and your continued support.

❤️

how can we upgrade from locally build addons to image based addons?

When the image tag is present in the add-on configuration, it is picked up.

the supervisor seems to still try to build locally according to its log.

I'm not aware of such an issue, maybe file a report @ Supervisor instead?

@alexbelgium
Copy link
Author

Thanks! I'll double check then file on supervisor with logs. Have a great day

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