-
Couldn't load subscription status.
- Fork 709
Description
What is the problem you're trying to solve
Breakout of #4021.
Also see overall Dockerfile analysis for context.
Refresher:
- we clone too much in size (full history), while we do not need it - github clones for a cold-cache run account for about 1G of content
- we clone too often - we should only ever clone any given project once per run
Describe the solution you'd like
Suggesting that:
- we git clone --quiet (less noise on the logs)
- we git clone --depth 1 (reduce network traffic and cache size)
- we separate clone and build - one clone when building multi-arch, and use mounts for build to avoid unnecessary copies (reduce network traffic and cache size)
For reference, one way to do it:
- clone once : https://github.com/farcloser/lepton/blob/main/Dockerfile#L278-L290
- build multi-arch with mount: https://github.com/farcloser/lepton/blob/main/Dockerfile#L534
Note that if we want to keep building using other projects build scripts, we would have to bind mounts RW (as most of these scripts do not allow to build out of tree). I personally believe we should build directly ourselves in most cases instead of relying on Makefiles / scripts (see #4021 for reasons).
If we do not want that, or not feasible in certain cases, we just need a simple lock to prevent cross-platforms builds from conflicting: https://github.com/farcloser/lepton/blob/main/Dockerfile#L753-L755
Let me know if that plan (1, 2, 3) is fine or if you prefer something else.
Additional context
No response