Ad

How To Cache Composer Packges In Jenkins

- 1 answer

I've got a Laravel project and simple pipeline in Jenkins which build Docker image from Dockerfile, pull code in it and execute composer install. Everything working fine so far, but installing composer packages takes a lot of time (like 6-7 minutes). I've tried to persist vendor directory somewhere, create symlink to it or something but nothing worked so far. I wonder if there is some better more official way to handle that? Anyone has some idea or experience in it? Or maybe some different CI tool?

Ad

Answer

Ok, I ended up with two solutions:

  1. I mounted composer cache directory to some directory in host to speed up composer packages installing:
dockerfile {
  filename 'Dockerfile'
  args '-v $HOME/composer_cache:/.composer/cache'
}
  1. There is (not so obvious, because Jenkins panel is little messy) option to disable workspace clean up before/after code checkout. One can delete those steps in pipeline configuration under "Branch Sources" section (with red X above those "Behaviours").
Ad
source: stackoverflow.com
Ad