Setting up a custom OpenCPU server

The below installs your Github repo into the Docker container using a small Dockerfile.

In summary:

  1. Launch an OpenCPU instance
  2. Build a new OpenCPU image with your Github custom package
  3. Push the image to the Container Registry for safe-keeping
  4. Stop the default OpenCPU docker container and launch your own

Launch an OpenCPU Instance


## start an opencpu template
vm <- gce_vm(name = "opencpu", template = "opencpu", predefined_type = "n1-standard-2")

## wait for opencpu image to load
gce_check_container(vm, "opencpu")

Build a new OpenCPU image

This Dockerfile is available via get_dockerfolder("opencpu-installgithub") and below. It installs an OpenCPU package from my prediction of user URLs for prefetching application.

The Dockerfile is used to build the custom image below:


In this case we don’t start a new instance, just stop the running OpenCPU container and start our own. We need to stop the default container to free up the ports 80 and 8004 that are needed for OpenCPU to work.

Clean up when you are done to avoid charges.