Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shiny server in Docker #34

Closed
leafyeh7 opened this issue Apr 18, 2018 · 6 comments
Closed

Shiny server in Docker #34

leafyeh7 opened this issue Apr 18, 2018 · 6 comments

Comments

@leafyeh7
Copy link

My goal is to create a docker container that can handle PDF download (through rmarkdown) in Shiny server.

rmarkdown: version 1.9
tinytext: version 0.5

After installing tinytext (with tinytex::install_tinytex()), I have no idea on how to "restart" the system because it's in the docker environment, and systemctl is not available in the debian build.

tinytex:::is_tinytex()
returns
FALSE

Is there a way to enable the tinytex without 'restarting' the system?

Thank you.

@yihui
Copy link
Member

yihui commented Apr 18, 2018

You may see this docker image for an example of installing TinyTeX in docker: https://github.com/rocker-org/rocker-versioned/blob/master/verse/Dockerfile

@leafyeh7
Copy link
Author

Thank you @yihui. It worked!

I followed the part where TinyTex is installed.

RUN wget -qO- \
    "https://github.com/yihui/tinytex/raw/master/tools/install-unx.sh" | \
    sh -s - --admin --no-path \
  && mv ~/.TinyTeX /opt/TinyTeX \
  && /opt/TinyTeX/bin/*/tlmgr path add \
  && tlmgr install metafont mfware inconsolata tex ae parskip listings \
  && tlmgr path add \
  && Rscript -e "source('https://install-github.me/yihui/tinytex'); tinytex::r_texmf()" \
  && chown -R root:staff /opt/TinyTeX \
  && chmod -R g+w /opt/TinyTeX \
  && chmod -R g+wx /opt/TinyTeX/bin \

Now tinytex:::is_tinytex() returns [1]TRUE

Interestingly enough I was just reading the same docker file and I was led to the TinyTex FAQ. Barely missed the part about the TinyTex installation.

@yihui
Copy link
Member

yihui commented Apr 18, 2018

Good to know!

@yihui yihui closed this as completed Apr 18, 2018
@frank0434
Copy link

Want to achieve the same objective as @leafyeh7

First I tried to install tinytex via DOCKERFILE using

RUN Rscript -e "install.packages("tinytex")"

But the tinytex was installed as root. R will complain couldn't find pdflatex.

Found this issue and put #34 (comment) into my dockerfile.

After run docker-compose build, had errors

mv: cannot stat 'texlive/*': No such file or directory
rm: cannot remove 'texlive': No such file or directory
rm: cannot remove 'install-tl-*': No such file or directory
sh: 27: /root/.TinyTeX/bin/*/tlmgr: not found
/bin/sh: 1: /opt/TinyTeX/bin/*/tlmgr: not found

wondering if there is a way to solve this?

Thank you in advance for any feedback.

@cderv
Copy link
Contributor

cderv commented Feb 18, 2021

First know that

install.packages("tinytex")

will install the tinytex R packages and not TinyTeX, the LaTeX distribution. That is why pdflatex is not found because you did not installed LaTeX.

If you want to follow rocker project example I would look at their new dockerfile and scripts to have example on how they install TeX Live on docker.

You can also follow FAQ 6 and 7 https://yihui.org/tinytex/faq/ to see how to install as an admin on Linux.

We also now have a new installation process for binary on linux could also help maybe: https://yihui.org/tinytex/#installation

You'll need to get the paths right, and the user access also. You could maybe do that from R in with tinytex::install_tinytex but you will get a user installed version so this needs to be done with the same user that will run the code in your container.

Hope it helps

@frank0434
Copy link

Thanks very much for the reply, @cderv
Got it worked in our internal cluster system.

Ended up using a hybrid Dockerfile from the rocker project repo.
I still need to manually change the user group for the directory /usr/local/ inside the container.

docker exec -it <container name> bash
chown -R root:shiny usr/local/

This happened after deployed the container but before I want to knit a PDF document.

Here is what I put into the dockerfile with the second script you pointed out for TinyTex installation.

FROM rocker/shiny:4.0.3
LABEL maintainer jian.liu@plantandfood.co.nz

ENV CTAN_REPO=http://mirror.ctan.org/systems/texlive/tlnet
ENV PATH=/usr/local/texlive/bin/x86_64-linux:$PATH


RUN /rocker_scripts/install_verse.sh

RUN install2.r --error -r $CRAN --skipinstalled tinytex
RUN install2.r --error --deps TRUE -r $CRAN --skipinstalled \
   influxdbr shiny shinydashboard shinyjs ggplot2 DT data.table plotly openssl knitr rmarkdown

COPY ./* /srv/shiny-server/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants