skip to Main Content

I’m trying to build a Docker container to develop PDF reports for download through an R Shiny app. As such, I am installing TinyTeX to manage all the dependencies. I have my build setup through a Dockerfile and a dummy report at the end that should run and initialize any files needed to make it work. I have tried this on both hub.docker.com and my local machine with no success. My local install of RStudio runs the Shiny apps successfully.

My minimal Dockerfile is:

FROM rocker/r-ver:4.3.2

RUN apt-get update && apt-get install -y 
    sudo 
    pandoc 
    pandoc-citeproc 
    && apt-get update && apt-get upgrade -y
    && apt-get clean && apt-get autoremove --purge

RUN R -e "install.packages(c('rmarkdown','tinytex')); tinytex::install_tinytex(force=TRUE)"

COPY dummy.Rmd /root/dummy.Rmd

RUN R -e "rmarkdown::render('/root/dummy.Rmd',output_file='dummy.pdf')"

and dummy.Rmd is

---
title: "Dummy Report"
author: "Me"
date: "`r Sys.Date()`"
output: 
  pdf_document:
    extra_dependencies: ["booktabs","anyfontsize"]
documentclass: article
classoption: a4paper
header-includes:
  - usepackage{booktabs}
  - usepackage{longtable}
  - usepackage{array}
  - usepackage{multirow}
  - usepackage[table]{xcolor}
  - usepackage{wrapfig}
  - usepackage{float}
  - usepackage{colortbl}
  - usepackage{pdflscape}
  - usepackage{tabu}
  - usepackage{threeparttable}
  - usepackage[normalem]{ulem}
  - usepackage{anyfontsize}
  - usepackage[]{fancyhdr}
---

## R Markdown
Sample Text

No matter which mirror I set, I am getting some variation of the message:

cannot contact mirror.ctan.org, returning a backbone server!
/root/.TinyTeX/bin/x86_64-linux/tlmgr: TLPDB::from_file could not initialize from: https://www.ctan.org/tex-archive/systems/texlive/tlnet/tlpkg/texlive.tlpdb
/root/.TinyTeX/bin/x86_64-linux/tlmgr: Maybe the repository setting should be changed.
/root/.TinyTeX/bin/x86_64-linux/tlmgr: More info: https://tug.org/texlive/acquire.html
! LaTeX Error: File `multirow.sty' not found.
! Emergency stop.

whether I am running this build locally or on the docker hub server.

tinytex::is_tinytex() returns TRUE.

Edit: Fixed syntax error and dependency error, but does not reproduce the error.

2

Answers


  1. Chosen as BEST ANSWER

    Konrad Rudolph's comment on datawookie's answer was correct; the tidyverse image adds a lot of other dependencies. I simplified the image a lot by using a rocker script still in the image.

    Dockerfile:

    FROM rocker/r-ver:4.3.2
    
    RUN apt-get update && apt-get install -y 
        sudo 
        pandoc 
        pandoc-citeproc 
        && apt-get update && apt-get upgrade -y
        && apt-get clean && apt-get autoremove --purge
    
    # Copied these next lines from rocker scripts to properly install texlive
    ENV CTAN_REPO=https://mirror.ctan.org/systems/texlive/tlnet
    ENV PATH=$PATH:/usr/local/texlive/bin/linux
    RUN /rocker_scripts/install_texlive.sh
    
    RUN R -e "install.packages(c('rmarkdown','tinytex'))"
    
    COPY dummy.Rmd .
    
    #The dummy markdown should automatically install all the needed dependencies for further .Rmd files
    RUN R -e "rmarkdown::render('dummy.Rmd')"
    

    Thank you all for your help! I'm not sure what was causing the original problem, but it was most likely a misconfigured installation. And my own inexperience (read incompetence). I apologize for not submitting a runnable reduced problem that replicated the issue, but thank you for helping me resolve it regardless.


  2. In your original Dockerfile you should have

    RUN R -e "install.packages(c('rmarkdown','tinytex'));"
    

    The two package names need to be passed as a vector, so wrap them in c().

    I’d suggest rather using the rocker/tidyverse base image though, which is set up for using TinyTeX.

    FROM rocker/tidyverse:4.3.2
    
    RUN Rscript -e 'tinytex::install_tinytex()'
    
    ENV PATH="${PATH}:/root/.TinyTeX/bin/x86_64-linux/"
    
    RUN tlmgr install 
            multirow 
            colortbl 
            wrapfig 
            pdflscape 
            varwidth 
            threeparttable 
            ulem 
            anyfontsize 
            fancyhdr
    
    COPY dummy.Rmd .
    CMD R -e "rmarkdown::render('dummy.Rmd')"
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search