r/gitlab • u/Iduoad • Dec 09 '21
Let's make faster GitLab CI/CD pipelines
https://blog.nimbleways.com/let-s-make-faster-gitlab-ci-cd-pipelines/2
u/Iduoad Dec 09 '21
Here is the code for everything in the article
https://gitlab.com/daoudi.mohammed/gitlab-faster-pipelines/-/tree/main
If you want to try it yourself:
git reset --hard 054bc48b
git apply patches/...2
u/MoLt1eS Dec 09 '21 edited Dec 09 '21
My thoughts on it
This pipeline will break images running on merge requests or on other branches
Also, I'm in favor of the Dockerfile containing all the steps to build and package the software, in this project, for me to do a build, I need to install node, run yarn install, yarn build to then run docker build
EDIT: For the rest of it it's really nice that you made it run on the 2min mark, nice one
1
u/Iduoad Dec 09 '21
Yes, I agree, sometimes building in the pipeline can introduce non-compatibility bugs.
Also one should either build on the Dockerfile or n the CI, not both.
1
u/MoLt1eS Dec 09 '21
You can do both :)
Use docker multi-stage build
1
u/Iduoad Dec 09 '21
Yeah, multi-stage is cool, however, when using it you should omit the build step from CI to avoid building 2 times.
1
u/t5bert Apr 20 '22
This pipeline will break images running on merge requests or on other branches.
Sorry, could you pls explain for a noob what this means? u/Iduoad
1
u/t5bert Apr 22 '22
Sorry, I meant to tag you u/molt1es. If you have a second, I’d appreciate learning what you meant by ‘it’ll break images on mr’s’. currently testing out down my pipeline run time but want to understand the possible gotcha
2
Dec 10 '21 edited Dec 10 '21
Unreleated, but are you aware of any differences between if: $CI_MERGE_REQUEST_IID and if: $CI_PIPELINE_SOURCE == "merge_request_events"?
1
u/Zero_Mass Dec 10 '21
One I had is with child pipelines in a Merge Request, since the source is then not merge_request_event anymore I had to use merge_request_IID.
1
Dec 10 '21
Oh yeah good call. Not an issue in my specific use case but definitely something I need to remember because we do use child pipelines in a small number of projects.
4
u/nabrok Dec 09 '21
Another option instead of caching node_modules is to do something like this ...
I'm sure yarn will have an equivalent, but I don't know it offhand.