-
Notifications
You must be signed in to change notification settings - Fork 112
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
Proposal: use ko to build a multi-platform lifecycle image #631
Comments
Just had a couple questions below but my feeling is this could be a big win in reducing our build process code/complexity, especially for upcoming proliferation of lifecycle image architectures. Having our foundational (and trusted) lifecycle binaries and images being built each time from the same A side benefit is also having another Windows OCI image implementation in the wild to both increase image prevalence and solidify support from Microsoft. After taking a look, a couple questions came up:
|
No. To accomplish this you'd probably have to In other words, whether or not buildpacks ends up literally adopting |
Thanks, that makes sense - I put this on the agenda for the implementations sub-team discussion this Thurs 11:30am EST/EDT (15:30 UTC). You're more than welcome to join and speak to it, and I'll be sure to bring it up otherwise. We'll see if we can get some thoughts from maintainers and others. |
From what I recall of the mentioned sub-team discussion, @ekcasey was of the opinion that we can't build the lifecycle with |
Yeah that sounds familiar. I'm fine to close this. |
Splitting off discussion from #435 as this is only one possible path forward for supporting Arm.
Background
The process for building the lifecycle image today, as I understand it, roughly speaking, is to:
go build ./cmd/lifecycle
*lifecycle
binary is available aslifecycle/detector
,lifecycle/analyzer
, etc.tools/packager/main.go
to:lifecycle.toml
to set the versionlifecycle
binary, and its symlinks, to a gzipped tar file**.tools/image/main.go
to add that gzipped tar to a base image and either push it to a registry, or load it in the local docker daemon.This process is described in the
Makefile
roughly twice, once forlinux/amd64
images and once forwindows/amd64
. The release process then combines these those two images into the multi-platform manifest list that ends up being available atbuildpacksio/lifecycle
.* for Linux today this is done by
docker run
ning analpine
togo build
with musl libc available, since some code uses cgo (though it might not after #630 🤞 )** tar file generation is slightly complicated by having to build an image for Windows. For Windows, paths in the tar file get prepended with
Files/
, somePAXRecords
are set on executable files, probably lots more I don't understand yet.This process clearly works fine today, the project is able to produce a lifecycle image for
linux/amd64
andwindows/amd64
, which is no small feat. But adding support for other platforms (e.g., arm), might become cumbersome without refactoring.Proposal
This model of
go build
ing, targzing and appending to a base image is really powerful, since Go makes cross-compilation really easy. If you don't require cgo, you can justGOOS=windows go build./
from any platform. Building and tarring and pushing an image doesn't even require a Docker daemon.This is, at its core, what
ko
does to build multi-arch images (and soon, Windows images too 🤞) -- it takes a base image (distroless, alpine, nanoserver, etc.), finds all the os/arch combinations it supports, runsgo build
for each of those, appends the binary as a layer on each platform base image, and pushes the resulting manifest list.I'd like to propose using
ko
to build the lifecycle image. Instead of two parallel processes that build forlinux/amd64
andwindows/amd64
, you couldko publish --platform=all
atop a base image manifest list supporting all your desired platforms*One wrinkle is the addition of symlinks.
ko
doesn't support this workflow today, and since it's pretty unique to lifecycle I'm not sure it would. Luckily, you can achieve this by appending a new layer to theko
-built image containing your symlinks, and the templatized lifecycle.toml. Even this could be achieved without writing new code, by usingcrane append
.* you'd have to stitch together a base image that supports both Linux and Windows from existing base images -- I wrote a simple tool to produce a stitched manifest list. Tekton is exploring a similar approach, since they already use
ko
to build multi-arch Linux images, but are starting to look into Windows support.Concretely, the build process for multi-platform lifecycle could be:
Obviously there's things I've missed and changing the release process for a project like this is no small undertaking.
ko
is just one option for accomplishing this, and if it's not the right one I completely understand. At the very least removing the cgo depdendency should allow the linux/windows build processes to become more similar, which should make adding other variants simpler.As a maintainer of
ko
andgo-containerregistry
(which bothko
and buildpacks use heavily), I'm happy to make any reasonable changes or additions to either to enable this. Especially since I suspect Tekton will benefit greatly from this, both in terms of taking advantage of multi-platform buildpacks images, and in cribbing from your release processes. 😄cc @ekcasey @micahyoung
The text was updated successfully, but these errors were encountered: