Deploy R api plumber scripts, HTML files or other images create the Docker image, add the build to Cloud Build and deploy to Cloud Run

cr_deploy_run(
  local,
  remote = basename(local),
  dockerfile = NULL,
  image_name = remote,
  tag = "$BUILD_ID",
  region = cr_region_get(),
  bucket = cr_bucket_get(),
  projectId = cr_project_get(),
  launch_browser = interactive(),
  timeout = 600L,
  ...
)

cr_deploy_html(
  html_folder,
  remote = basename(html_folder),
  image_name = remote,
  tag = "$BUILD_ID",
  region = cr_region_get(),
  bucket = cr_bucket_get(),
  projectId = cr_project_get(),
  launch_browser = interactive(),
  timeout = 600L,
  ...
)

cr_deploy_plumber(
  api,
  remote = basename(api),
  dockerfile = NULL,
  image_name = remote,
  tag = "$BUILD_ID",
  region = cr_region_get(),
  bucket = cr_bucket_get(),
  projectId = cr_project_get(),
  launch_browser = interactive(),
  timeout = 600L,
  ...
)

Arguments

local

A folder containing the scripts and Dockerfile to deploy to Cloud Run

remote

The folder on Google Cloud Storage, and the name of the service on Cloud Run

dockerfile

An optional Dockerfile built to support the script. Not needed if 'Dockerfile' exists in folder. If supplied will be copied into deployment folder and called "Dockerfile"

image_name

The gcr.io image name that will be deployed and/or built

tag

The tag or tags to be attached to the pushed image - can use Build macros

region

The Cloud Run endpoint set by CR_REGION env arg

bucket

The Cloud Storage bucket that will hold the code

projectId

The projectId where it all gets deployed to

launch_browser

Whether to launch the logs URL in a browser once deployed

timeout

Amount of time that this build should be allowed to run, to second

...

Arguments passed on to cr_buildstep_run

name

Name for deployment on Cloud Run

image

The name of the image to create or use in deployment - gcr.io

allowUnauthenticated

TRUE if can be reached from public HTTP address. If FALSE will configure a service-email called (name)-cloudrun-invoker@(project-id).iam.gserviceaccount.com

concurrency

How many connections each container instance can serve. Can be up to 80.

port

Container port to receive requests at. Also sets the $PORT environment variable. Must be a number between 1 and 65535, inclusive. To unset this field, pass the special value "default".

max_instances

the desired maximum nuimber of container instances. "default" is 1000, you can get more if you requested a quota instance. For Shiny instances on Cloud Run, this needs to be 1.

memory

The format for size is a fixed or floating point number followed by a unit: G, M, or K corresponding to gigabyte, megabyte, or kilobyte, respectively, or use the power-of-two equivalents: Gi, Mi, Ki corresponding to gibibyte, mebibyte or kibibyte respectively. The default is 256Mi

cpu

1 or 2 CPUs for your instance

env_vars

Environment arguments passed to the Cloud Run container at runtime. Distinct from env that run at build time.

gcloud_args

a character string of arguments that can be sent to the gcloud command not covered by other parameters of this function

html_folder

the folder containing all the html

api

A folder containing the R script using plumber called api.R and all its dependencies

Details

cr_deploy_html

Deploy html files to a nginx server on Cloud Run.

Supply the html folder to host it on Cloud Run. Builds the dockerfile with the html within it, then deploys to Cloud Run

Will add a default.template file to the html folder that holds the nginx configuration

cr_deploy_plumber

The entrypoint for CloudRun will be via a plumber script called api.R - this should be included in your local folder to deploy. From that api.R you can source or call other resources in the same folder, using relative paths.

The function will create a local folder called "deploy" and a tar.gz of that folder which is what is being uploaded to Google Cloud Storage

See also

For scheduling Cloud Run apps cr_run_schedule_http

These deploy containers to Cloud Run, a scale 0-to-millions container-as-a-service on Google Cloud Platform.

cr_deploy_run_website which has more features like rending Rmd files and deploying upon each git commit

Other Deployment functions: cr_deploy_docker_trigger(), cr_deploy_docker(), cr_deploy_packagetests(), cr_deploy_pkgdown(), cr_deploy_run_website(), cr_deploy_r()

Examples

if (FALSE) { cr_project_set("my-project") cr_region_set("europe-west1") cr_bucket_set("my-bucket") cr_deploy_run(system.file("example/", package = "googleCloudRunner")) } if (FALSE) { cr_project_set("my-project") cr_region_set("europe-west1") cr_bucket_set("my-bucket") cr_deploy_html("my_folder") } if (FALSE) { cr_project_set("my-project") cr_region_set("europe-west1") cr_bucket_set("my-bucket") cr_deploy_plumber(system.file("example/", package = "googleCloudRunner")) }