This topic describes how to push your R app to Cloud Foundry and how to configure your R app to use the R buildpack.
Note: This buildpack is not distributed as part of Pivotal Application Service (PAS) v2.4. However, it is supported for use with PAS. You can download an offline version of this buildpack from Pivotal Network.
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
You can find the list of supported R versions in the R buildpack release notes.
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 -fas the start command for a web app with the entrypoint
web: R -f simple.r
Option 2: Specify a start command with
$ cf push r-app -c "R -f simple.r"
Option 3: Specify a start command in the application manifest by setting the
commandattribute. For more information, see the Deploying with Application Manifests topic.
For more information about starting apps, see Starting, Restarting, and Restaging Applications.
As of v0.0.5, the following packages are provided by the buildpack:
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. For example:
--- packages: - cran_mirror: https://cran.r-project.org num_threads: 2 packages: - name: stringr - name: jsonlite
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.
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: - packages: - name: stringr - name: jsonlite
cf push uploads your vendored dependencies. The buildpack installs them directly from the
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.
If you need to use a proxy to download dependencies during staging, you can set
https_proxy environment variables. For more information, see the Proxy Usage Documentation.
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.
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.