The below installs your Github repo into the Docker container using a
small Dockerfile
.
In summary:
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.
FROM opencpu/base
MAINTAINER Mark Edmondson ([email protected])
# install any package dependencies
RUN apt-get update && apt-get install -y \
nano \
## clean up
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/ \
&& rm -rf /tmp/downloaded_packages/ /tmp/*.rds
## Install your custom package from Github
RUN Rscript -e "devtools::install_github(c('MarkEdmondson1234/predictClickOpenCPU'))"
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.
## stop default opencpu container
docker_cmd(vm, "stop opencpu-server")
## run custom opencpu server
docker_run(vm,
image = "opencpu-predictclick",
name = "predictclick",
detach = TRUE,
docker_opts = "-p 80:80 -p 8004:8004")
Clean up when you are done to avoid charges.