[SOLVED] Building Docker Images after running PHP Composer

Hello everyone,

How do I prevent the CI from deleting a folder (Composer’s vendor directory) that’s not in the repo on every build?


In my docker-ci.yml one of the job runs composer install, then does a login to a Docker Registry (GitLab’s Container Registry), builds a Docker Image (Dockerfile does a COPY of content to new image), then pushes that Docker Image. So a new layer is added to that Image on every build. The problem is that the new layer is far too large even if I just change a small text file. I figured out the reason: every time the build runs it removes the vendor folder that is created on composer install. So any time composer install is run it has to recreate the vendor folder and install all the dependencies. Normally composer install would skip the rebuild of dependency directory since I have a composer.lock file and so the Docker Image layer would be the size of whatever I change and not the size of the vendor directory.

I can’t figure out how to prevent the build from removing the vendor directory.



TIL about caching in gitlab-ci.yml.