--- title: "IDE container: Rstudio and Shiny server and more" output: BiocStyle::html_document: toc: true toc_depth: 4 number_sections: false highlight: haddock css: style.css --- ## Introduction The goal of this `tengfei/sevenbridges` docker image is to provide - SDK environment that includes - Command line uploader - Seven Bridgs Command line tools - sevenbridges R package - Rstudio server - Shiny server ## Docker container ### Build container locally The Dockerfile is included with the package in `inst/docker` folder. Here is the current content of Dockerfile ```{r comment=''} fl <- system.file("docker/sevenbridges/", "Dockerfile", package = "sevenbridges") cat(readLines(fl), sep = '\n') ``` You can simply build it locally, enter folder which contain that dockerfile, in this case, it's under `inst/docker/sevenbridges` ``` docker build -t tengfei/sevenbridges . ``` ### Pull from docker hub A hook is added to build the docker image automatically from my [github](https://github.com/tengfei/sevenbridges), it's under `inst/docker`, it's automatically build on my dockerhub [page](https://hub.docker.com/r/tengfei/sevenbridges/). you can directly use this `tengfei/sevenbridges`. Everytime a push is made in the github repos, the docker container is re-built. ## Launch Rstudio server from docker container For example, you can ssh into your AWS instance, here I suppose you already have docker installed, and pull the image ``` docker pull tengfei/sevenbridges ``` To launch sevenbridges Rstudio server image, I recommend you read this [tutorial](https://github.com/rocker-org/rocker/wiki/Using-the-RStudio-image) Or following the quick instruction here ``` docker run -d -p 8787:8787 tengfei/sevenbridges docker run -d -p 8787:8787 -e USER= -e PASSWORD= rocker/rstudio ``` You will be able to access the Rstudio in the browser by something like `http://:8787` Sometimes you want to add more users, to add users ``` ## Enter the container docker exec -it bash ## Interactively input password and everything else adduser ``` ### Launch both Rstudio and Shiny server from same docker container Sometimes it's very conventient to launch both Rstudio and Shiny server from a singel container and your users can manage to using Rstudio and publish Shiny apps at the same time in the same container. To do so, just pull the same image and launch them at different port. ```shell docker run -d -p 8787:8787 -p 3838:3838 --name rstudio_shiny_server tengfei/sevenbridges ``` check out the ip from docker machine if you are on mac os. ```bash docker-machine ip default ``` In your browser, `http://:8787/` for Rstudio server, for example, if 192.168.99.100 is what returned, visit `http://192.168.99.100:8787/` for Rstudio. For shiny server, __per user app__ is hosted `http://:3838/users//`, for example, for user `rstudio` (a default user) and an app called `01_hello`, it will be `http://:3838/users/rstudio/01_hello/`. To develop your shiny app from Rstudio server, you can login your rstudio server with your username, and create a fold at home folder called `~/ShinyApps` and develop shiny apps under that folder, for example, you can create an app called `02_text` at `~/ShinyApps/02_text/`. Let's try this, please login your rstudio at `http://:8787` now, then try to copy some example over to your home folder under `~/ShinyApps/` ```r dir.create("~/ShinyApps") file.copy("/usr/local/lib/R/site-library/shiny/examples/01_hello/", "~/ShinyApps/", recursive = TRUE) ``` If you are login as username 'rstudio', then visit `http://192.168.99.100:3838/rstudio/01_hello` you should be able to see the hello example. Note: Generic shiny app can also be hosted `http://:3838/` or for particular app, `http://:3838/` and inside the docker container, it's hosted under `/srv/shiny-server/`