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

[speedup] Avoid updating package list when no package is to be installed #31

Open
douglas-raillard-arm opened this issue Oct 1, 2021 · 2 comments

Comments

@douglas-raillard-arm
Copy link
Contributor

When no package needs to be installed, we could skip downloading the package list, saving some precious seconds:

    if [ "$ALPINE_PACKAGES" != ' ' ]; then
        apk update
        apk add $ALPINE_PACKAGES
    fi

This is particularly relevant for the following use case:

  1. setup a chroot
  2. unmount fs using the destroy script
  3. Once we have that setup in a cache, we can spin up Alpine "lightweight chroot" almost instantly using:
  4. mount an overlayfs to avoid modifying the underlying cached Alpine root
  5. call alpine-chroot-install in the overlayfs to set it up (bind mounts, sysfs, procfs, /etc/resolv.conf etc). This time, the package list is empty since they are already installed.
  6. Do something in the chroot (e.g. build some code)
  7. Destroy the chroot and unmount/remove the overlayfs upper layer

I am using that system in order to compile in a known environment C sources generated on the fly, so the time it takes to spin up a "fresh" chroot is critical, hence the caching.

@jirutka
Copy link
Member

jirutka commented Oct 1, 2021

I’ll add it, but please consider that this script has never been designed for this use case. It was meant for CI, nothing else. I’m planning to write another script specifically for the use case you’re mentioning, I need it even for myself.

@douglas-raillard-arm
Copy link
Contributor Author

Interesting, do you plan on adding it to the same repo or will it land somewhere else ? I would definitely check it out when it comes to life. This sort of tooling is partly why I chose Alpine for that lean build "container" (and also because of static linking).

Thanks a lot

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

No branches or pull requests

2 participants