GitLab CI: reuse the same image in two independent parallel jobs

Viewed 3215

I am currently building two Latex documents in parallel using the aergus/latex container as follows (a Makefile is available in the repository):

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

This works as expected, but it pulls the image twice (it is the slowest step in this simple pipeline, since the documents have few pages/slides). Is there any way to share the image across the two jobs, effectively pulling it only once, while keeping the jobs running in parallel?

1 Answers

All the jobs are independent, to speed up your process you can use the Shell Executor https://docs.gitlab.com/runner/executors/ to make it faster

With this executor you will be able to use local docker images.

The first job will download the image from the docker hub and the next ones will get from the local docker service.

But if you are using other executors or Gitlab Shared Runner, this is the normal behaviour

Related