You’re right, at that time we don’t know the version, it seems the base image uses the current version + tests-passed branch, although the branch will have the commit at the time in which the image was build.
Wouldn’t the way it’s doing now have slower rebuilds, even when tests-passed branch is used?
Just consider the following instructions:
In the base image:
git clone --depth 1 https://github.com/discourse/discourse.git
cd discourse/
git remote set-branches --add origin tests-passed
In web.template.yml
git reset --hard
git clean -f
git remote set-branches --add origin master
git pull
...
Update
I tested the above steps again and they were fast. I guess I run another instruction on the 1st try that changed the git tree and ended up trying to pull everything when I run git pull.