Google Cloud Build mount volume in another path

Viewed 781

Locally I run this command in order to build a PDF file:

docker run -it -v $PWD:/doc/ -v $PWD/fonts/:/usr/share/fonts/external/ thomasweise/texlive sh -c 'xelatex *.tex'

And I have a cloudbuild.yaml file to build on Google Cloud

steps:
  - name: thomasweise/texlive
    entrypoint: sh
    args:
      - -c
      - |
        xelatex *.tex
  - name: gcr.io/cloud-builders/gsutil
    args: ["cp", "*.pdf", "gs://storage.skhaz.io"]

But my build fails because I need to mount a extra volume: -v $PWD/fonts/:/usr/share/fonts/external/

How can I translate the command above to cloudbuild.yaml?

1 Answers

As you can see in the documentation, you can achieve this in 2 steps

#1st step: Create the volume and populate it
- name: 'gcr.io/cloud-builders/gcloud'
  volumes:
  - name: 'vol1'
    path: '/usr/share/fonts/external'
  entrypoint: 'bash'
  args:
  - '-c'
  - |
        cp /workspace/path/to/fonts/* /usr/share/fonts/external/

# Then, use the volume with your fonts in it
- name: thomasweise/texlive
    entrypoint: sh
    args:
      - -c
      - |
        xelatex *.tex
  volumes:
  - name: 'vol1'
    path: '/usr/share/fonts/external'
Related