简体   繁体   English

如何避免在.gitlab-ci.yml的每个阶段之前安装requirements.txt?

[英]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.我只需要安装一次,这样stageAstageB都可以使用。

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.

相关问题 pip 安装 environment.yml 就好像它是 requirements.txt - pip installing environment.yml as if it's a requirements.txt 在 GitLab 中创建 requirements.txt - Creating requirements.txt in GitLab 如何在 gitlab-ci.yml 中将 postgis 扩展添加到 postgresql 数据库 - How to add postgis extension to postgresql database in gitlab-ci.yml Gitlab Flask Page: Problems with installing python GDAL package for Frozen Flask Application with.gitlab-ci.yml file - Gitlab Flask Page: Problems with installing python GDAL package for Frozen Flask Application with .gitlab-ci.yml file 如何在 Google Cloud Platform、App Engine 中执行 pip install -r requirements.txt(不使用 Gitlab CI)? - How can I execute pip install -r requirements.txt inside Google Cloud Platform, App Engine (without using Gitlab CI)? 如何在 PyCharm 中指定用于从 requirements.txt 安装的 pip 选项 - How to specify pip options in PyCharm for installing from requirements.txt 如何避免将开发包放入 requirements.txt - How to avoid putting dev packages in requirements.txt 我的 first.gitlab-ci.yml 文件:如何在 CI/CD 中运行现有文件 - My first .gitlab-ci.yml file: How to run existing files in CI/CD 如何在 Gitlab 中为简单的 hello world 程序配置 gitlab-ci.yml - How do I configure gitlab-ci.yml for a simple hello world program in Gitlab 阻止Docker在每个版本上安装python软件包要求(没有requirements.txt) - Prevent Docker from installing python package requirements on every build (without requirements.txt)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM