Renkulab has always supported R and RStudio as part of its interactive sessions. The canonical way of sharing your data science project to the world is of course R Shiny. In this post we show you how you can deploy R Shiny applications directly from your Renkulab project.
- we will be using shinyapps.io as a hosting service so make an account there before proceeding.
- your RenkuLab project is assumed to be in R, hopefully a recent version of Renku and R
- you have a sample application, either in a single file like this app or in a ui.R+server.R combination, like this app
A sample set up is at Renku.
Add your application files to your RenkuLab repository.
Touch up your application in RStudio. In order to view the application in the interactive session, you will need to add the following line in your Dockerfile:
Once that is installed, you should be able to view an application using the “Run App” button:
Once you are happy with your changes, push your changes to git and exit the interactive session.
.gitlab-ci.ymlfile to include the pattern as shown in the sample project. The section containing the SHINY variables defines the resulting app URL. In this case, the shinyapps account is
gavin-k-leeand has the application name
my-shiny-dashboard. The shiny server is the free shinyapps.io site - this can be configured to be RSConnect or another (paid) hosting solution if you have one.
In this case:
image_buildsection should be untouched as this is the tag from which interactive sessions are built.
shiny_image_buildbuilds another (identical) image which is necessary since the proceeding step does not use the
update_dashboardsection updates the R Shiny dashboard.
- Add the right credentials: navigate to the Settings → CI/CD section in the Renkulab GitLab:
You will need 3 variables:
- The SHINY_TOKEN and SHINY_SECRET can be obtained from your http://shinyapps.io/ account at shinyapps.io
- The CI_PUSH_TOKEN is generated from the project’s own Personal Access Token page:
Create this token and add it to the variables as in the previous instruction. You should allow
- Check that with each commit to your repository (either from http://renkulab.io/ sessions or locally), your CI/CD pipeline succeeds. This may take a while, especially for the first time or if you have many changes.
Navigate to your application name: in this case gavin-k-lee.shinyapps.io/my-shiny-dashboard.
The magic: now any changes to your application which are pushed to your Renkulab project will be automatically pushed to shinyapps.io! It will take a minute or two to be updated, but you can check the progress of the pipeline by looking at the CI/CD section in Renkulab’s GitLab.
Happy dashboarding! Note that free accounts on shinyapps.io are limited to 5 applications, but this should be sufficient for many users.
Credits: Tao Sun, Rok Roskar