What is this?
R, Shiny, and Cloud Foundry are an immensely powerful combination for developing and hosting data-analytics web applications. This sample shows how little is necessary to get an R Shiny application deployed in Cloud Foundry using the R buildpack.
To run the demo
Clone this repository, go to the directory containing these files, ensure you're logged into Cloud Foundry, then push the application:
After a while of watching R modules compile, you'll see output similar to this:
Waiting for app to start... name: shiny-example requested state: started routes: shiny-example-kind-wallaby.app.cloud.gov last uploaded: Thu 14 Feb 00:28:58 PST 2019 stack: cflinuxfs3 buildpacks: r type: web instances: 1/1 memory usage: 256M start command: R -f app.R state since cpu memory disk details #0 running 2019-02-14T08:29:22Z 0.0% 44K of 256M 227M of 1G
To run a different demo
Set the variable
EXAMPLE_NAME in the application's environment to the directory name of the Shiny demo you'd like to run, then restart it:
cf set-env shiny-examples EXAMPLE_NAME <name-of-example> ; cf restart shiny-example
If you've selected an example which requires particular R packages to be installed, it may not work! In that case, you can edit
r.yml to list the missing packages, then
cf push to redeploy.
If the example requires a lot of packages, you may find that the
cf command is timing out before the application is fully deployed. You can set a longer timeout in minutes using the
CF_STAGING_TIMEOUT environment variable before pushing the application:
CF_STAGING_TIMEOUT=30 cf push
What each file does
r.ymlspecifies a CRAN repository and the R packages that the sample application needs to operate.
Procfiletells the R buildpack what command to run to start the application.
app.Rcontains some simple R code to check the environment for the
EXAMPLE_NAMEthat the application should run (if supplied), then starts that example as an app listening on the
PORTsupplied by Cloud Foundry.
manifest.ymlsets the name of the app and limits memory usage to 256M, and requests a random route to avoid collisions with other users running this sample in the same Cloud Foundry.
See CONTRIBUTING for additional information.
This project is in the public domain within the United States, and copyright and related rights in the work worldwide are waived through the CC0 1.0 Universal public domain dedication.
All contributions to this project will be released under the CC0 dedication. By submitting a pull request, you are agreeing to comply with this waiver of copyright interest.