electricitymaps / brick

Simple monorepo build tool based on Docker
20 stars 1 forks source link

Remove promotion/re-tagging feature #94

Closed skovhus closed 3 years ago

skovhus commented 3 years ago

The promoting of images (re-tagging images matching a hash) was introduced in https://github.com/tmrowco/brick/pull/57. Back then it showed an improvement for first build on a branch from 8 minutes to 2 minutes.

But an unforeseen side-effect it that promoting an image steals the latest tag. This means that master builds needs cannot reuse images that matches the hash.

I suggest we either:

madsnedergaard commented 3 years ago

Hmm, wouldn't this mean all work on new branches will slow down 4x again, or have we made improvements since then that would help? 🤔

What's the reason merge->master builds use the latest tag, could we do something about that instead of the other way around?

skovhus commented 3 years ago

Hmm, wouldn't this mean all work on new branches will slow down 4x again, or have we made improvements since then that would help? 🤔

The initial build on a branch will be slower. Not sure how much slower... We would need to test that out.

What's the reason merge->master builds use the latest tag, could we do something about that instead of the other way around?

So the dependency hashing can be seen here. It finds images that has the same label as what we are currently building AND that they also have the same dependency hash. On master and on branches we build latest images.

Let me try to illustrate this a bit. So currently this a flow illustrating how the promotion works (newest event first).

With promotion of latest tags from other branches:

Without promotion:

With promotion of any non-latest tags from other branches:

Maybe worth explaining in person! :D

madsnedergaard commented 3 years ago

Haha yeah, it's a bit complicated without a whiteboard - but you did a pretty good job anyway! 💪

We can also talk about this in person tomorrow, but posting here nonetheless so that I at least remember it 😄

A few questions/ideas:

  1. Could we "duplicate"/copy from an image with a new feature-branch tag instead of "stealing" latest? (like creating new branch from another branch in git)

Example:

  1. What if master didn't rely on :latest tag, but instead used :master labels to find latest image?

Example:

  1. How does all of this play together with what we do in projects/deploy.sh > tag_and_push_docker_compose() where we tag all used images as :production? Is that only "locally" on instance-1 that we do it?
skovhus commented 3 years ago

I haven't observed the issue here since we upgraded our Docker version.