Created
December 14, 2017 07:30
-
-
Save prog/b716b815ed4ec05d8ca57adc90be9e97 to your computer and use it in GitHub Desktop.
How to use composer (php) including cache with gitlab-ci
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
build:install-vendor: | |
stage: build | |
image: <any-image-with-composer> | |
before_script: | |
- composer config -g cache-dir "$(pwd)/.composer-cache" | |
script: | |
- composer install --ignore-platform-reqs --no-dev --optimize-autoloader --no-ansi --no-interaction --no-progress | |
cache: | |
paths: | |
- .composer-cache/ | |
artifacts: | |
expire_in: 30 min | |
paths: | |
- vendor/ |
I know. this is nothing to do with this, but why can't GitLab simply cache ~/.composer ?
@bertalanimre GitLab CI Caches by definition have the scope of the app aka the Git repository only. The repo resides in the working directory. This directory may be located in different locations depending of the runner setup. Broadly speaking, the CI process does not know anything else about the environment, like the existence of home directories (~
/ $HOME
) or which tool you use in your jobs (composer
). Therefore you need to tell the tool to store its cache files in the working directory. This allows GitLab to pick them up.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
probably because ~/.composer is somewhere in the container that has the composer command