This buildpack downloads and installs R into a Scalingo app image.
The following instructions should get you started:
- Initialize a new git repository wherever you want:
% mkdir my-r-app
% cd my-r-app
% git init
- Create the Scalingo app:
% scalingo create my-r-app
-
Add some R packages, if needed.
-
Deploy:
% git push scalingo master
- Start a
console
one-off:
(This will only work if you have a console
process type defined in your
Procfile
.)
scalingo --app my-r-app run --type console
The platform considers the app as a R app if:
- a file called
run.R
,app.R
,plumber.R
,init.R
orR-packages
exists at the root of your project.
Warning
The platform only installs R. If you need a specific framework such asplumber
orshiny
, you still have to ask the buildpack to install it.
During the BUILD
phase, this buildpack:
- Downloads R if necessary (when the requested version is not in cache).
- Compiles and installs R with the following options:
--enable-java=no
--enable-recommended-packages=no
--enable-R-shlib=yes
--without-x
- Downloads and installs the requested R packages, if any.
- Validates the build.
🎉 This process results into a scalable image that includes the configuration, ready to be packaged into a container.
By default, the release script creates a console
process type which is
(currently) ignored by Scalingo.
If you need this console
process type, add a Procfile
at the root of your project and add the console
process type:
console: R --no-save
Moreover, if a file called run.R
, app.R
or plumber.R
exists at the root
of the project, the release
script also creates a web
process type with the
following command:
R --file=${HOME}/{run,app,plumber}.R --gui-none --no-save
Consequently:
-
if you don't need the
web
process type, make sure to scale it to zero:scalingo --app -my-r-app scale web:0
-
if you need to run another command, add (or update) your
Procfile
to specify how to start yourweb
process.
The buildpack uses a specific file called R-packages
to install R packages.
The R-packages
expects one package name per line, with the corresponding
version separated by a single space character.
Version can be set to latest
or *
. It can also be omitted, in which case it
will be interpreted as latest
.
Warning
Due to R internals, there are 2 ways of installing a package:
- If you chose to install the
latest
version of a package, R is able to automatically download and install it, along with its dependencies.- If you need a specific version of a package, R is not able to automatically download and install its dependencies. You will have to ask the buildpack to install each dependency in the appropriate order.
For example, the following R-packages
file...
rlang 1.0.2
ellipsis *
fansi latest
shiny
...will result in the following actions:
- The buildpack will download and install
rlang 1.0.2
, - it will automatically install the latest version of
ellipsis
(this package depends onrlang
, previously installed), - it will automatically install the latest version of
fansi
(this package depends ongrDevices
andutils
, installed with R), - it will automatically install all
shiny
dependencies and then the latest version ofshiny
.
Note: when a specific version of a package is required (i.e. not latest
), the
buildpack tries to keep the compiled package in cache for future deployments.
The following environment variables are available for you to tweak your deployment:
Version of R to use.
Defaults to 4.0.0