[英]How to avoid installing requirements.txt before every stage in .gitlab-ci.yml?
I have a .gitlab-ci.yml
which looks like this:我有一个
.gitlab-ci.yml
它看起来像这样:
image: "python:3.7"
before_script:
- pip install -r requirements.txt
stages:
- stageA
- stageB
stage_a:
stage: stageA
script:
- run_some_python_scripts
stage_b:
stage: stageB
script:
- run_more_python_scripts
With this setup, requirements.txt
is installed before every stage.使用此设置,
requirements.txt
会在每个阶段之前安装。 I need it installed only once, such that both stageA
and stageB
can use.我只需要安装一次,这样
stageA
和stageB
都可以使用。
How can I achieve this?我怎样才能做到这一点?
One option I've found that works great if the requirements.txt
file doesn't change much, is to bake it into your own Docker image.如果
requirements.txt
文件没有太大变化,我发现一个很好的选择是将其烘焙到您自己的 Docker 图像中。
Another option which I personally don't like as much, is to use a virtualenv
and then use GitLab's cache on the virtualenv
, however this can be a bit slow if there are a lot of pip
packages.我个人不太喜欢的另一个选择是使用
virtualenv
,然后在virtualenv
上使用 GitLab 的缓存,但是如果有很多pip
包,这可能会有点慢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.