YunoHost / issues

General issue tracker for the YunoHost project
72 stars 8 forks source link

Pre-compile packages for faster install/upgrade #2281

Open selfhoster1312 opened 11 months ago

selfhoster1312 commented 11 months ago

Discussed during the last Yunocamp

It would be great, especially for lower end systems where compilation is super slow or fails due to low memory available, to have pre-compiled packages for Yunohost applications. For example, invidious can take several minutes to install even on a powerful machine.

There's two sides for pre-compilation:

There's also the question of how to distribute these pre-packaged assets:

For backend programs, there's also the question of linking against system libraries. Most programs will require using libc, openssl, or libpcre. The binary layout of the ABI changes with many releases, which is why some folks do static linking against a specific version. Here's the pros and cons:

Some flavors to explore for binary distribution:

Another option is to pre-compile binary objects to be linked dynamically on the Yunohost instance, because the linking step is usually fast and low on resource usage. I will post more information where i ran practical tests

selfhoster1312 commented 11 months ago

Case study: invidious

Tried approaches:

I went with the last option because we can cross-compile to a different architecture/libc using a container/VM and it should not break across upgrades.

$ docker run --rm -it crystallang/crystal:latest-alpine sh
# apk add sqlite-static
# git clone https://github.com/iv-org/invidious
# cd invidious
# make STATIC=1
# # PUBLISH `invidious` somewhere

I've started work on a Github action to automate it but so far i find it "meh". See here. So instead i've used gh command line to publish a release with my own build artifacts. I'll revisit this soon.

There's the question of how to cross-compile to other architectures, but this should be easily done with qemu. There's many OCI images and github actions to address this i just haven't tried them so far, and i need to put my hands on an original Raspberry Pi to confirm if it works.

If you wanna try this pre-compiled package (amd64 only) it's here:

yunohost app install -a "domain=tube.DOMAIN.TLD&path=/&init_main_permission=visitors" -l youtube https://github.com/selfhoster1312/invidious_ynh

I still have a lot of stuff to do (fix upgrade script, make sure locales and prebuilt binary stay in sync, etc) it's just a demo don't use it for real folks. But to give an example, it took 44.676s to install on my server, while the "real" invidious package took 3m33,825s.

alexAubin commented 6 months ago

Related (example use case) : https://github.com/YunoHost-Apps/synapse_python_build