Bootstrapping a new Shiny app or migrating a pre-existing Shiny application
Last updated
Last updated
You've deployed the previous example and want to start building an R Shiny application from scratch or migrate a pre-existing app. The easiest way to do either is to clone as a template.
If you're starting to develop a R Shiny app from scratch -- this process is easy. Login to GitHub, go to , and click the Use this template button.
This will create a new repository based of heroku-docker-r-example-app
. You can clone this new repository and use it as a base for your R Shiny application.
You can now begin development using the IDE of your choice.
Go to and generate a new repository using Use this template.
Migrating a pre-existing R Shiny application requires a few more steps. The following workflow is our preferred and supported method, but, for the adventurous, all you need is the Dockerfile
, heroku.yml
and run.R
files from the repository.
You must have run.R present in any Shiny project for it to run on Heroku
Clone the newly created repository and add your pre-existing code.
The template defaults to using R 3.6.1.
The determines which version of R is used for your code in Heroku.
If you use a diferent version of R, replace 3.6.1 with the desired version of R. At present, we support R 3.5.x to 3.6.1.
If you want to use R 3.5.1, your Dockerfile should look like
However, in order for your application to work properly in Heroku, you must ensure that:
You do not use install.packages()
anywhere in your code. This will cause R to install packages during application runtime, rather than before the application is launched. There is one exception to this rule when installing libraries from GitHub, explained in #3.
If you're installing custom R packages from GitHub using the devtools
library, add an init.R
file to your repository and move these installation functions to init.R
. All instructions in this file will be executed during the build process, before your application goes live.
If you're familar with and use it, you're in good shape. If not, Packrat is a R library dependency management tool which automatically downloads and builds all libraries required for your application. The R Shiny IQSS toolchain automatically installs Packrat when you deploy your application. No additional steps are necessary.
All your R libraries required with library()
exist in .