Compile binaries, publish multiple docker images, one per architecture

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.

  1. Compile binaries to dist/bin/<binary_name>-<arch> (irrelevant for non-compiled like Ruby or Node)
  2. 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, sometimes latest as well).
  3. Push a manifest for <org>/<repo>:<version> (for multiple version) that references the deployed <org>/<repo>:<version>.

For each stage:

  1. I think I can get 1 from just having a compile step that uses the relevant image (e.g. golang) and instead of go build and go test, wrap it in a for loop for arch in Dockerfile.*; do... GOARCH=... go build etc. Is that correct? Or is there a better way?
  2. How would I do this? Do I need to have multiple invocations of the docker plugin, one per arch?
  3. manifest plugin

Is this correct? Are there better patterns here?

Thanks in advance.

This is pretty much what we did for Drone 0.8.
You can see an example in our yaml:

Thanks @bradrydzewski. So one image created and pushed per pipeline entry. I see you and @tboerger as the primary contributors, so will open an issue there with a suggestion.