R buildpack
Page last updated:
You can push your R app to Cloud Foundry and configure your R app to use the R buildpack.
Cloud Foundry automatically uses the R buildpack if it detects a
r.yml
file in the root directory of your project.
If your Cloud Foundry deployment does not have the R buildpack installed, or the installed version is out of date,
you can use the latest version by specifying it with the -b
option when you push your app.
For example:
$ cf push my_app -b https://github.com/cloudfoundry/r-buildpack.git
Supported versions
You can find the list of supported R versions in the R buildpack release notes.
Start command
The R buildpack does not generate a default start command for your applications. Instead, you must specify a start command for your app.
To stage an app with the R buildpack and start the app, do one of the following:
Option 1: Supply a Procfile. For more information about Procfiles, see Production Server Configuration. The following example Procfile specifies
R -f
as the start command for a web app with the entrypointsimple.r
:web: R -f simple.r
Option 2: Specify a start command with
-c
:$ cf push r-app -c "R -f simple.r"
Option 3: Specify a start command in the application manifest by setting the
command
attribute. For more information, see the Deploying with Application Manifests topic.
For more information about starting apps, see Starting, Restarting, and Restaging Applications.
Specifying app dependencies
As of v1.1.21, the following packages are provided by the R buildpack:
- Rserve
- forecast
- plumber
- shiny
To specify additional packages needed by your app, provide the CRAN mirror and names of the packages inside your r.yml
file. You can also specify the number of threads to use for parallel installation. Optionally, you can also specify the dependencies
argument of install.packages
, which defaults to TRUE
when left out. For example:
---
packages:
- cran_mirror: https://cran.r-project.org
num_threads: 2
dependencies:
- Depends
- Imports
packages:
- name: stringr
- name: jsonlite
Vendoring app dependencies
If you are deploying in an environment that is disconnected from the Internet, you must vendor your app’s dependencies, which means you must make these packages available for offline use. You can vendor dependencies by using a package manager.
To set up your own custom, local CRAN-like repository to vendor your packages, create the src/contrib
directories and populate them with your package source tarballs. For more information, see How to Set Up a Custom CRAN-like Repository published on the Packrat Documentation site.
Add the src/contrib
directories containing your package tarballs to a vendor_r
directory at the root of your app. This directory is named vendor_r
so as not to conflict with vendor directories of other languages, such as python.
Then, inside your r.yml
, provide the names of your vendored packages in the packages
list:
--- packages: - packages: - name: stringr - name: jsonlite
cf push
uploads your vendored dependencies. The buildpack installs them directly from the vendor_r/
directory.
Example app directory tree:
├── r.yml
├── simple-app.r
└── vendor_r
└── src
└── contrib
├── PACKAGES
├── PACKAGES.gz
├── jsonlite_1.5.tar.gz
└── stringr_1.3.1.tar.gz
For more information about using buildpacks in disconnected environments, see Disconnected environments.
Proxy support
If you need to use a proxy to download dependencies during staging, you can set
the http_proxy
and https_proxy
environment variables. For more information, see Using a Proxy.
BOSH configured custom trusted certificate support
R uses certificates stored in /etc/ssl/certs
. Your platform operator can configure the platform to add the custom certificates into the application container. For more information, see Configuring Trusted System Certificates for Applications.
Help and support
Join the #buildpacks channel in our Slack community if you need any further assistance.
For more information about using and extending the R buildpack in Cloud Foundry, see the R-buildpack GitHub repository.
You can also find current information about this buildpack on the R buildpack release page in GitHub.
View the source for this page in GitHub