Emit events for building images
What I did
Right now docker compose build or docker compose up --build does not emit events. The only way to notice that something was built is by looking at stdout. The only case events are written (to stderr) is when using BuildKit in dry-mode (there's special code to emit some fake events in that case).
This PR makes building emit proper events (one before and one after building). This improves using docker compose from other programs. (Especially together with #11478.)
Related issue Fixes #11403.
(not mandatory) A picture of a cute animal, if possible in relation to what you did

@ndeloof could you maybe take a look at this PR at some point? Thanks :)
@ndeloof can you take a look at this? Thanks.
Are these events also generated if the image is built by the docker compose watch command?
I would assume so; I've never used docker compose watch or looked at how it works. But I would assume it uses the same code as docker compose up and docker compose build.