GitLab-CI Multi Runner php composer cache

本小妞迷上赌 提交于 2019-12-08 23:09:32

问题


I'm using gitlab-ci-multi-runner with docker containers. Everything is going fine, but docker containers don't keep the composer cache so in every run composer downloads dependencies again and again, which takes a lot of time. Is there any way to configure gitlab-ci-runner docker container to keep the composer cache or mount a volume on each run where the composer cache is kept?


回答1:


You could modify the composer cache path and write the stuff to a docker volume.

That storage is persistent and can be shared across containers.

Referencing:

  • https://gitlab.com/gitlab-org/gitlab-runner/blob/master/docs/configuration/advanced-configuration.md#volumes-in-the-runnersdocker-section
  • https://docs.docker.com/engine/admin/volumes/volumes/



回答2:


You can change the composer cache path by exporting the COMPOSER_CACHE_DIR environment variable in your runner configuration file, and then add a volume in the [runners.docker] section to match it.

If you run gitlab-runner as root or with sudo, then your configuration file is located at /etc/gitlab-runner/config.toml. Otherwise it's located at $HOME/.gitlab-runner/config.toml.

# config.toml

[[runners]]
  name = "Generic Docker Runner"
  ...
  environment = ["COMPOSER_CACHE_DIR=/cache"]
  executor = "docker"
  [runners.docker]
    ...
    volumes = ["/var/cache:/cache:rw"]
    cache_dir = "/cache"


来源:https://stackoverflow.com/questions/33479574/gitlab-ci-multi-runner-php-composer-cache

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!