Use pdflatex in the default share runner from Gitlab

Problem

I’m testing the share runner provided by Gitlab. However, I mostly want to use it to build documents using (La)TeX and friends (pdflatex, xelatex, lualatex, etc.). However, with a simple configuration it doesn’t work.

Naive pdflatex

For example

build:
  script:
    - pdflatex doc.tex

Naive tag

I tried adding a tag to see if executing a docker will make a difference (as I understood from here that a tag will instantiate a different runner), through

build:
  script:
    - pdflatex doc.tex
  tags:
    - docker

Full installation of texlive

That still gives an error that the pdflatex command is not found. So I thought, “OK, it is not by default on the system” so I will try to install it

before_script:
  - apt-get update -qq && apt-get install -y -qq texlive-full
  - pdflatex --version

build:
  script:
    - pdflatex doc.tex
  tags:
    - docker

That seems to provide a solution but it takes forever to install (around 30 minutes per build) the full version of texlive to use it in the system. Also, note that the simple solution of installing texlive (without all the packages) still results on errors as some packages may be needed that are not in this lightweight installation.

Questions

  • So, is there a way of running (La)TeX (and friends) out of the box with the default share runners provided by Gitlab?

  • What is (and how) the best way to create pdfs using (La)TeX (and friends) through the default share runners provided by Gitlab?

  • Also, if the installation of texlive is a viable solution, is there a way to avoid installing everything every single time?

As per http://doc.gitlab.com/ce/ci/docker/using_docker_images.html#how-to-use-other-images-as-services you should be able to use any Docker image available at Docker Hub.

There are many texlive images available: https://hub.docker.com/search/?isAutomated=0&isOfficial=0&page=1&pullCount=0&q=texlive&starCount=0

I’m not sure this will speed up compilation though, unless Gitlab CI keeps images around.

1 Like

Will be any security issues using an unknown third party image?

For what I read, the docker creates a new image every time, isn’t it? So, it should be safe, I guess? Correct me if I’m wrong.

Just wondering if I have a private repo, whether the info on it will remain private or it will be published somewhere?

Hey, thank you for this thread, got me started on this.

I ended up using a similar .gitlab-ci.yml

compile_resume:
  image: tianon/latex
  script:
    - pdflatex resume.tex
  artifacts:
    paths:
      - resume.pdf

So I have resume.pdf as an artifact.
It takes around 5 minutes. I am not in a hurry and not paying for this, so it is acceptable.

Improvements would be:

  • upload/commit artifact to the repo itself?
  • using latexdiff to compile the diffed version (how to access the previous commit inside the build?)

Don’t know about security when using the docker image. Guess you could create an account, fork an image and acquire a bit of control?

Edit: I found this and will try to setup .gitlab-ci.yml to use:
git latexdiff HEAD~1

2 Likes