In the last couple weeks I have been setting up my first pipeline using the public shared runners on GitLab.com for a php project in a private repository. The pipeline is pretty simple at this point, defining two stages:
stages:
- test
- deploy
The test stage runs composer update -o
to build the project dependencies, connects to a remote database server, and runs the CodeCeption testing framework to test the build and generate code coverage reports.
The deploy stage runs composer update --no-dev -o
to rebuild the project with only the production dependencies and uses rsync to push the files to the production webserver.
This is all working right now, but for each stage it runs the whole process of pulling the docker image, installing dependencies, and extracting the project from git. It seems like it would be a whole lot more efficient to just load the docker image and project once, then run the test and deploy stages one after the other using the same persistent build instance.
I realize that many times you do want to create a fresh instance for each stage, but with my project I feel like this is rather inefficient for time and server resources.
I could configure everything to run in the same stage, which would eliminate the redundant docker image process, but I would lose the pipeline functionality in GitLab where you can see which stages failed, and make later stages dependent on the success of the preceding ones.
From my review of the documentation and several related questions, it seems like this might have to do with the the architecture of how this process works, where jobs are independent of each other (and can even be processed by different runners) and are organized into stages on a pipeline.
What I have is certainly workable, (if a little slow) but I thought I would ask the question here in case there was something I was missing that would make this process more efficient while still retaining the CI pipeline functionality.
.gitlab-ci.yml
? Also, checkout out Gitlab CI's cache and artifacts to skip the full dependency build on every execution. See here – Tremolitethecodingmachine/php:7.3-v2-cli
) which allowed me to avoid having to compile php extensions each time and saves several steps in my yml file. I am thinking this is probably the best I can do when using the public shared runners. – Finlay