I am trying to figure out how to build multiple binaries, one per os/arch combination (when relevant), and push out multiple docker images, one per os/arch combination.
My usual pattern looks like this. I have a Dockerfile.<arch>
which is unique to that arch (sometimes it is the FROM
that changes, sometimes the COPY
, etc.), but also acts as flags as to which archs I want to build/distribute for.
- Compile binaries to
dist/bin/<binary_name>-<arch>
(irrelevant for non-compiled like Ruby or Node) - Build and push images with
<org>/<repo>:<version>-<arch>
, which there are multiple versions (I almost always include the git hash, short or long, since tags are free, sometimeslatest
as well). - Push a manifest for
<org>/<repo>:<version>
(for multiple version) that references the deployed<org>/<repo>:<version>
.
For each stage:
- I think I can get 1 from just having a compile step that uses the relevant image (e.g.
golang
) and instead ofgo build
andgo test
, wrap it in a for loopfor arch in Dockerfile.*; do... GOARCH=... go build
etc. Is that correct? Or is there a better way? - How would I do this? Do I need to have multiple invocations of the docker plugin, one per arch?
- manifest plugin
Is this correct? Are there better patterns here?
Thanks in advance.