RStudio and Shiny in one docker file

I am considering dockerdistributing an application shinythat also requires RStudio. The main goal is a simple installation in hospitals under Windows. Anything that requires entering characters in black boxes will certainly not succeed when installed by non-IT people.

My previous attempts have used a stroller, but installing strollers in itself has proven to be an obstacle.

The repository rockerhas RStudio and Shiny, and for my own installation work together. However, I would like to create a combined application to simplify the installation.

What is the recommended workflow? Start with RStudio and manually add Shiny? Or combine code docker files from both Rockers, starting with r-base? Or use a layout tool?

+4
source share
4 answers

An interesting question, but I'm not sure that I understand the advantage of using shiny-server and rstudio-server instances from the same container.

Is the goal that the two containers have the same R libraries (for example, so that the package does not need to be installed separately on each) or just have one docker container instead of two? The simple execution of two docker commands instead of one does not seem so burdensome, but perhaps I underestimate it.

, , , , .

, docker-esque / , . (, - ) .

, , .

, rstudio :

docker run --name rstudio -v /usr/local/lib/R/site.library rocker/rstudio true

( RStudio- , :)

docker run --name rstudio -dP -v /usr/local/lib/R/site.library rocker/rstudio

site.library rstudio , :

docker run --volumes-from rstudio -dP rocker/shiny

, clobbers site.library shiny. , rstudio , , . , :

Docker's -volumes-from?

.

+3

Docker, , , / . docker-compose. docker-compose yaml, rstudio, , docker-gen Jason Wilder. R-, , Rocker Rocker -. , . RStudio, / root. Rocker RStudio wiki:

:

  • your_user
  • SOME_USER RStudio
  • SOME_PASS Rstudio
  • *. DOMAIN.tld , A .

nginx1:
  image: nginx
  container_name: nginx
  ports:
  - "80:80"
  - "443:443"
  volumes:
    - /etc/nginx/conf.d
    - /etc/nginx/vhost.d
    - /usr/share/nginx/html
    - /home/your_user/services/volumes/proxy/certs:/etc/nginx/certs:ro

nginx-gen:
  links:
    - "nginx1"
  image: jwilder/docker-gen
  container_name: nginx-gen
  volumes:
    - /var/run/docker.sock:/tmp/docker.sock:ro
    - /home/your_user/services/volumes/proxy/templates/nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl:ro
  volumes_from:
    - nginx1
  entrypoint: /usr/local/bin/docker-gen -notify-sighup nginx -watch -only-exposed -wait 5s:30s /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf

rstudio:
  links:
    - "nginx1"
  image: rocker/hadleyverse
  container_name: rstudio
  ports:
    - "8787:8787"
  environment:
    - VIRTUAL_PORT=8787
    - ROOT=TRUE
    - VIRTUAL_HOST=rstudio.DOMAIN.tld
    - USER=SOME_USER
    - PASSWORD=SOME_PASS

shiny:
  links:
    - "nginx1"
  image: rocker/shiny
  container_name: shiny
  environment:
    - VIRTUAL_HOST=shiny.DOMAIN.tld
  volumes:
    - /home/your_user/services/volumes/shiny/apps:/srv/shiny-server/
    - /home/your_user/services/volumes/shiny/logs:/var/log/
    - /home/your_user/services/volumes/shiny/packages:/home/shiny/

, , , docker-compose .

+6

  • R
  • RStudio ()
  • Shiny Server ( )

, @Dieter Menne. ops, dev (, envs, mac, windows ..).

Centos 6, env. .

:

FROM centos:centos6.7
MAINTAINER enzo smartinsightsfromdata 

RUN yum -y install epel-release
RUN yum update -y && yum clean all
# RUN yum reinstall -y glibc-common
RUN yum install -y locales java-1.7.0-openjdk-devel tar

# Misc packages

RUN yum groupinstall -y "Development Tools" 

# R devtools pre-requisites:
RUN yum install -y wget git xml2 libxml2-devel curl curl-devel openssl-devel


WORKDIR /home/root
RUN yum install -y R

RUN wget http://cran.r-project.org/src/contrib/rJava_0.9-7.tar.gz
RUN R CMD INSTALL rJava_0.9-7.tar.gz
RUN R CMD javareconf \
    && rm -rf rJava_0.9-7.tar.gz

#-----------------------

# Add RStudio binaries to PATH
# export PATH="/usr/lib/rstudio-server/bin/:$PATH"
ENV PATH /usr/lib/rstudio-server/bin/:$PATH 
ENV LANG en_US.UTF-8

RUN yum install -y openssl098e supervisor passwd pandoc

# RUN wget http://download2.rstudio.org/rstudio-server-rhel-0.99.484-x86_64.rpm
# Go for the bleading edge:
RUN wget https://s3.amazonaws.com/rstudio-dailybuilds/rstudio-server-rhel-0.99.697-x86_64.rpm
RUN yum -y install --nogpgcheck rstudio-server-rhel-0.99.697-x86_64.rpm \
    && rm -rf rstudio-server-rhel-0.99.484-x86_64.rpm

RUN groupadd rstudio \
    && useradd -g rstudio rstudio \
    && echo rstudio | passwd rstudio --stdin 

RUN R -e "install.packages(c('shiny', 'rmarkdown'), repos='http://cran.r-project.org', INSTALL_opts='--no-html')"
RUN wget https://download3.rstudio.org/centos5.9/x86_64/shiny-server-1.4.0.756-rh5-x86_64.rpm
RUN yum -y install --nogpgcheck shiny-server-1.4.0.756-rh5-x86_64.rpm \
    && rm -rf shiny-server-1.4.0.756-rh5-x86_64.rpm

RUN mkdir -p /var/log/shiny-server \
    && chown shiny:shiny /var/log/shiny-server \
    && chown shiny:shiny -R /srv/shiny-server \
    && chmod 777 -R /srv/shiny-server \
    && chown shiny:shiny -R /opt/shiny-server/samples/sample-apps \
    && chmod 777 -R /opt/shiny-server/samples/sample-apps 

COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
RUN mkdir -p /var/log/supervisor \
    && chmod 777 -R /var/log/supervisor


EXPOSE 8787 3838

CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] 

supervisord.conf:

[supervisord]
nodaemon=true
logfile=/var/log/supervisor/supervisord.log
pidfile = /tmp/supervisord.pid


[program:rserver]
user=root
command=/usr/lib/rstudio-server/bin/rserver
stdout_logfile=/var/log/supervisor/%(program_name)s.log
stderr_logfile=/var/log/supervisor/%(program_name)s.log
startsecs=0
autorestart=false

[program:shinyserver]
user=root
command=/usr/bin/shiny-server
stdout_logfile=/var/log/supervisor/%(program_name)s.log
stderr_logfile=/var/log/supervisor/%(program_name)s.log
autorestart=false

github: smartinsightsfromdata

pro on centos ( shiny server pro, 45 ).

+2

Some, unfortunately, there is no definite answer, it all depends on how much reuse you would be looking for and whether the basic image upstream is well supported. This is also the aspect ratio of the images, more layers, more the resulting image.

+1
source

All Articles