1

Is it possible to make a shiny app with flexdashboard as a package with the Open Analytics golem package? Is it possible to dockerize it afterwards? How is the workflow going from the flexdashboard .Rmd file?

My Dockerfile so far

FROM rocker/shiny-verse:latest 

MAINTAINER Tim M.Schendzielorz "tim.schendzielorz@googlemail.com"

# Install dependencies 

RUN  echo 'install.packages(c("dplyr","dbplyr","DBI","DT","plotly","flexdashboard","lubridate"), \
        repos="http://cran.us.r-project.org", \
        dependencies=TRUE)' > /tmp/packages.R \
        && Rscript /tmp/packages.R


# Copy configuration files into the Docker image
COPY shiny-server.conf  /usr/bin/shiny-server.conf
COPY shiny-server.sh  /usr/bin/shiny-server.sh

COPY flexdashboard.Rmd /usr/bin/flexdashboard.Rmd   

# make all app files readable (solves issue when dev in Windows, but building in Ubuntu)
RUN chmod -R 755 /usr/bin

# Add shiny user
RUN groupadd  user \
&& useradd --gid user --shell /bin/bash --create-home user

EXPOSE 3838



CMD ["R", "-e rmarkdown::run('/usr/bin/flexdashboard.Rmd')"]

I am new to Docker and it seems I need to add the Command to rmarkdown::run in the apps specs as mentioned here: Deploy Shiny app with Flexdashboard and start the shiny server with the standard shell command instead? Thank you Vincent for docktorrent, will try it now!

4
  • 2
    As it is, the question is not a good fit for the StackOverflow format, and is likely to get closed. (Too open, multiple questions, no report of previous attempts, no reproducible code). Though you may have better luck on a forum such as community.rstudio.com that would allow such a discussion to take place. Note: golem is primarily made by ThinkR, while Open Analytics makes ShinyProxy
    – Aurèle
    Oct 7, 2019 at 8:28
  • 2
    Hi, have a look to this article (use auto translate form English) and tweak the run function to use rmardown::run(). I will put something on github in the few days with an example.thinkr.fr/dockeriser-application-shiny Oct 7, 2019 at 18:17
  • 2
    I add an example here : github.com/VincentGuyader/docktorrent , this is for runtime: shiny_prerendered but you can adapt the functions Oct 7, 2019 at 20:59
  • Update 2020-29-01: I ended up deploying the Flexdashboard via Docker and Shinyproxy without golem, but will have a try on my next project. You can check out the Dockerfile I used here: medium.com/analytics-vidhya/… Jan 29, 2020 at 14:27

1 Answer 1

4

Just a side note, {golem} is not an Open Analytics package.

To answer the "Can we deploy flexdashboard with golem", yes:

The best way to achieve what you intend to do is to put your Rmd inside inst/, and modify run_app that way:

run_app <- function(...) {
  rmarkdown::run(
    system.file("md.Rmd", package = "mypackage")
  )
}

Note that for Docker you'll have to add library(mypackage) at the top of the Rmd if you need functions from inside mypackage.

That way, you can use the mypackage::run_app() function as a CMD for your Docker file.

Also, note that {golem} comes with a add_dockerfile() function that will bundle everything you need to install the app. But this won't bundle shiny server inside it.

See: https://rtask.thinkr.fr/shinyapp-runapp-shinyappdir-difference/, especially the part called RSTUDIO PRODUCTS 2/2: SETTING A SHINY SERVER FOR TESTING for an example of a Dockerfile setting a golem app + a shiny server.

Colin

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.