我有一个.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
使用此设置,requirements.txt
将在每个阶段之前安装。我只需要安装一次,这样stageA
和stageB
都可以使用。
我怎样才能做到这一点?
我发现,如果requirements.txt
文件没有太大变化,那么一个非常有效的选项是将其烘焙到您自己的Docker映像中。
另一个我个人不太喜欢的选项是使用virtualenv
,然后在virtualenv
上使用GitLab的缓存,但如果有很多pip
包,这可能会有点慢。