GitLab CI:在两个独立的并行作业中重用相同的图像

unv*_*hed 7 gitlab-ci

我目前正在Latex使用容器并行构建两个文档,aergus/latex如下所示(Makefile存储库中提供了一个文档):

stages:
  - compile

.compile_pdf_template:
  stage: compile
  image: aergus/latex

presentation:
  extends: 
    - .compile_pdf_template
  script:
    - make presentation
  artifacts:
    paths:
      - presentation.pdf

report:
  extends: 
    - .compile_pdf_template
  script:
    - make report
  artifacts:
    paths:
      - report.pdf
Run Code Online (Sandbox Code Playgroud)

这按预期工作,但它会拉取图像两次(这是这个简单管道中最慢的步骤,因为文档只有很少的页面/幻灯片)。有没有什么方法可以在两个作业之间共享图像,仅有效地拉取一次,同时保持作业并行运行?

Ser*_*aka 0

所有作业都是独立的,为了加快进程,您可以使用 Shell Executor https://docs.gitlab.com/runner/executors/来加快速度

有了这个执行器,您将能够使用本地 docker 镜像。

第一个作业将从 docker hub 下载镜像,下一个作业将从本地 docker 服务获取。

但如果您使用其他执行器或 Gitlab Shared Runner,这是正常行为