app_image: The name of the Docker image to create or use existing from Google Container Registry. Must be numbers, dashes or lowercase letters only.
dockerfolder: The folder location containing the Dockerfile and app dependencies
Returns
The instance
Details
To deploy a Shiny app, you first need to construct a Dockerfile which load the R packages and dependencies, as well as copying over the Shiny app in the same folder.
This function will take the Dockerfile, build it into a Docker image and upload it to Google Container Registry for use later.
If already created, then the function will download the app_image from Google Container Registry and start it on the instance provided.
Any existing Shiny Docker containers are stopped and removed, so if you want multiple apps put them in the same Dockerfile.
Dockerfile
Example Dockerfile's are found in system.file("dockerfiles",package = "googleComputeEngineR")
The Dockerfile is in the same folder as your shiny app, which consists of a ui.R and server.R in a shiny subfolder. This is copied into the Dockerfile in the last line. Change the name of the subfolder to have that name appear in the final URL of the Shinyapp.
This is then run using the R commands below:
Examples
## Not run:vm <- gce_vm("shiny-test", template ="shiny", predefined_type ="n1-standard-1")vm <- vm_ssh_setup(vm)app_dir <- system.file("dockerfiles","shiny-googleAuthRdemo", package ="googleComputeEngineR")gce_shiny_addapp(vm, app_image ="gceshinydemo", dockerfolder = app_dir)# a new VM, it loads the Shiny docker image from beforegce_shiny_addapp(vm2, app_image ="gceshinydemo")## End(Not run)
See Also
The vignette entry called Shiny App has examples and a walk through.