image-bootstrap icon indicating copy to clipboard operation
image-bootstrap copied to clipboard

Add support for generating Alpine Linux images

Open jonhoo opened this issue 8 years ago • 10 comments

It'd be really near if image-bootstrap also supported generating images for Alpine Linux, as it is a distro that is specifically designed to be small and secure (and therefore fits well as a cloud image). They also have cloud-init available as a package.

What would be the changes necessary to add another distro to image-bootstrap? I might be able to contribute some time to this if I'm pointed in the right direction.

jonhoo avatar Jul 18 '17 15:07 jonhoo

The Alpine Docker image may provide some useful insights too.

jonhoo avatar Jul 18 '17 15:07 jonhoo

Hi Jon,

a key question is if Alpine has some equivalent to debootstrap/directory-bootstrap already or if that part needs to be made as well. Do they have a tool for Alpine chroot creation?

hartwork avatar Jul 18 '17 22:07 hartwork

Not that I know of — we'd likely have to implement a chroot procedure similar to the one used for Arch

jonhoo avatar Jul 18 '17 22:07 jonhoo

Can you take over the research on what's needed in detail?

hartwork avatar Jul 18 '17 22:07 hartwork

I'll take a look and report back.

jonhoo avatar Jul 18 '17 22:07 jonhoo

Ah, interesting... So, looking at the Docker mkimage-alpine, Alpine Linux provides a statically linked binary of their package manager that can bootstrap the system. It's fetched here and invoked here. This procedure is documented in the official Alpine wiki. There is even an official alpine-chroot-install script that may be of use. My guess is that we can also use parts of the included setup-alpine script to finalize setup.

jonhoo avatar Jul 18 '17 22:07 jonhoo

Hi!

Some of these options look good, for some I have concerns:

  • Moby/mkimage-alpine.sh is by Moby, not by Alpine itself. I would expect the user to trust alpine code if he/she wants to bootstrap Alpine but nothing else, so not Moby (even if they're the best)
  • Installing Alpine Linux in a chroot looks excellent
  • alpine-chroot-install may do modifications to the host system, e.g. installing packages. If you search for "host", you find plenty. I'm not sure if that's cool for something to download and execute. On the other hand, if that exists maybe there is no point in duplicating all of that.

What do you think?

hartwork avatar Jul 19 '17 14:07 hartwork

Looking through the alpine-chroot-install script, it seems like all it's really doing is installing QEMU (which is the only reason it modifies the host afaict) and then following the "installing Alpine Linux in a chroot" wiki entry, so I think just following those steps is the way to go.

jonhoo avatar Jul 19 '17 15:07 jonhoo

@jonhoo The alpine-chroot-install script is not strictly necessary. The qemu installation is for cross-architecture installs, which is not intended to be implemented for now.

ghost avatar Dec 27 '17 16:12 ghost

Quick update regarding directory-bootstrap: Basic support for Alpine Linux just arrived. It downloads the latest mini chroot tarball, verifies its signature, and extracts the tarball.

hartwork avatar Mar 29 '18 22:03 hartwork