我有一个 .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
然后使用 GitLab 的 cache在 virtualenv
,但是如果有很多 pip
,这可能会有点慢包。
关于python - 如何避免在 .gitlab-ci.yml 的每个阶段之前安装 requirements.txt?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61516089/