I noticed something strange happening during build process during a multi-tasking bug fix. Turns out I was using Gitlab CI's caching incorrectly. I should have been using artifacts. Here's what I saw.
I quickly completed both, pushed them to gitlab and waited for the CI to complete. They both passed, but when I tested the bugfix, it still wasn't fixed, even though it was working on my dev machine.
Recollecting something similar had happened before, I manully reran the build, which fixed the issue.
The issue was the cache I had set up was being shared across all pipelines, so when two were running at the same time there was a race condition between the client being built (and stored and cached in the /dist folder) and the docker container being built (using the cached folder).
As the docs say, caches are shared between pipelines, artifacts are not.
So after removing the cache and extending the artifact on the
build job, all worked correctly.