The plumberDeploy
package separated the deployment and the do_*
functions from plumber
. The plumberDeploy
package gives the ability to automatically deploy a plumber API from R functions on ‘DigitalOcean’ and other cloud-based servers.
You can install the released version of plumberDeploy
from CRAN with (coming soon!):
And the development version from GitHub with:
If you’re just getting started with hosting cloud servers, the DigitalOcean integration included in plumberDeploy
will be the best way to get started. You’ll be able to get a server hosting your custom API in just two R commands. Full documentation is available at https://www.rplumber.io/articles/hosting.html#digitalocean-1.
plumberDeploy
. Validate your account with analogsea::account()
.analogsea::key_create
method or see https://www.digitalocean.com/docs/droplets/how-to/add-ssh-keys/to-account/.analogsea::droplets()
to confirm that it’s able to connect to your DigitalOcean account.mydrop <- plumberDeploy::do_provision()
. This will start a virtual machine (or “droplet”, as DigitalOcean calls them) and install Plumber and all the necessary prerequisite software. Once the provisioning is complete, you should be able to access port 8000
on your server’s IP and see a response from Plumber.analogsea::install_r_package()
.plumberDeploy::do_deploy_api()
to deploy or update your own custom APIs to a particular port on your server.Getting everything connected the first time can be a bit of work, but once you have analogsea
connected to your DigitalOcean account, you’re now able to spin up new Plumber servers in DigitalOcean hosting your APIs with just a couple of R commands. You can even write scripts that provision an entire Plumber server with multiple APIs associated.
Your ssh key needs to be available on your local machine too. You can check this with ssh::ssh_key_info()
. Validate that one of the public keys can be found in lapply(analogsea::keys(), '[[', "public_key")
.
.api/plumber.R
Then run this code
id <- plumberDeploy::do_provision(example = FALSE)
# About 10 minutes
# STOP Make sure every packages the api depends on is available on the droplet, see below for other commands.
plumberDeploy::do_deploy_api(id, "date", "./api/", 8000, docs = TRUE)
Navigate to: [[IPADDRESS]]/date/__docs__/
# Install package to your droplet
analogsea::install_r_package(droplet, c("readr", "remotes"))
# Install system dependencies to your droplet
analogsea::debian_apt_get_install(droplet, "libssl-dev","libsodium-dev", "libcurl4-openssl-dev")
R Packages installed on linux systems sometimes require system packages. Check console output carefully to see if a package was installed successfully.
Otherwise read the doc on functions, ask questions in the RStudio community or report issues to our github issue tracker.