From 65a7b0e768c3eed66ac6addfd0e4446435fe9017 Mon Sep 17 00:00:00 2001 From: Mark Edmondson Date: Sat, 6 Nov 2021 15:17:51 +0100 Subject: [PATCH] start #142 --- R/buildsteps_gce.R | 37 +++++++++++++++++++++++++++++++++++++ man/cr_setup_test.Rd | 14 ++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 R/buildsteps_gce.R diff --git a/R/buildsteps_gce.R b/R/buildsteps_gce.R new file mode 100644 index 00000000..de54f795 --- /dev/null +++ b/R/buildsteps_gce.R @@ -0,0 +1,37 @@ +#' Buildstep to deploy to Google Compute Engine +#' +#' This build step adds some helpers to \link{cr_buildstep_gcloud} for deploying to VMs to GCE +#' +#' @export +cr_buildstep_compute_rstudio <- function( + rstudio_user, + rstudio_pw, + vm_name = "rstudio", + template = "gcr.io/gcer-public/persistent-rstudio", + disk_name = "rstudio-disk", # do check to see if it exists, if it does attach + disk_size = "10GB", + machine_type = "n1-standard-1" +){ + + # https://cloud.google.com/compute/docs/containers/deploying-containers + # https://cloud.google.com/sdk/gcloud/reference/compute/instances/create-with-container + cr_buildstep_gcloud( + "gcloud", + args = c( + "compute", + "instances", + "create-with-container", + vm_name, + sprintf("--container-env=[ROOT=TRUE,USER=%s,PASSWORD=%s]", + rstudio_user, rstudio_pw), + sprintf("--container-image %s", template), + sprintf("--container-mount-disk=name=%s,mount-path=/home/%s", + disk_name, rstudio_user), + sprintf("--create-disk=name=%s,size=%s", disk_name, disk_size), + sprintf("--machine-type=%s", machine_type), + sprintf("--scopes=cloud-platform") + ) + + ) + +} diff --git a/man/cr_setup_test.Rd b/man/cr_setup_test.Rd index 1c622476..6512d5ad 100644 --- a/man/cr_setup_test.Rd +++ b/man/cr_setup_test.Rd @@ -14,6 +14,20 @@ cr_setup_test( \description{ This allows you to check if your setup works - run \link{cr_setup} first. } +\examples{ + +\dontrun{ +# start the menu for interactive use +cr_setup_test() + +# skip menu and run all tests +cr_setup_test("all") + +# run just the plumber deployment test +cr_setup_test("plumber") + +} +} \seealso{ Other setup functions: \code{\link{cr_setup_auth}()},