Skip to content

FASTGenomics/image-shiny-base

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Docker Base Image for R Shiny Apps on FASTGenomics

This is the FASTGenomics base image for R Shiny analyses. Clone this repository if you want to bring your own Shiny App to FASTGenomics. You can find an example Shiny analyses on FASTGenomics, and a basic Shiny tutorial here.

See also our FASTGenomics documentation on Working with Custom Docker Images.

Structure of this Repository

Directories

  • APP
    All your shiny app code and runtime data has to go here. At least an app.R file has to be present.
  • fg_config
    Don't modify this directory
    The files in this directory are required to correctly integrate your app into FASTGenomics.

Files

  • Dockerfile
    The instructions on how to build your docker container. You do not need to modify it, unless you want to
    • Use another base image
    • Install additional system packages
    • Copy additional data for the use during image building
  • install.R
    This Rfile is executed during image build. Usually it is used to install Rpackages.

Build Your Own Shiny App and Publish it on FASTGenomics

  1. Prerequisites. You need to have Docker Desktop installed on your computer as well as an user account at Docker.

  2. Clone this repository.

  3. Add your code and data. All your code and data goes to the APP directory. The whole folder and it's contents are available at runtime. It is mandatory that there is at least an app.R file which will get executed at container runtime (replace the existing one).

  4. Install additional packages. If your app requires additional packages there are usually two places to install them:

    • Dockerfile
      Add system libraries or packages via apt-get install. Just append the existing list.
      You can also select another base image by changing the FROM at the top of the Dockerfile. However, the rocker/shiny-verse is usually a good start as it contains shiny and all tidy-verse packages. Currently, we use it with R version 4.
    • install.R
      In this file you add all your code to install required R packages. Common commands to use are install.packages() or devtools::install_github(). The script will be executed during the build of the Docker image.
  5. Build your docker image. To build your Docker image just run the following command in the root directory of this repository:

    docker build -t <IMAGE_NAME> .

    <IMAGE_NAME> should be in the form <DOCKER_HUB_USERNAME>/<APP_NAME>:<TAG>. So if you want to build your app fancy_shiny as user fastgenomics for the first time, your tag could be version 1.0. Then, the command would be:

    docker build -t fastgenomics/fancy_shiny:1.0 .
  6. Test your docker image locally. Once your image is build, you should test it locally. To start it just run:

    docker run -p 3838:3838 <IMAGE_NAME>

    The first port number after -p flag defines the port on your host machine. You can change it to something else, just make sure to use it when starting the app. The second port number is the default internal port of the shiny app and is set to 3838. This must be the case for use in FASTGenomics.

    To see your app in action head over to your browser and type

    http://localhost:3838/proxy/shiny
    

    If anything goes wrong you can access the logs from within the docker container in the folder /var/log/shiny-server.

  7. Push your image to Docker Hub. The final step is to push your image to Docker Hub by using:

    docker push <IMAGE_NAME>

    In our example this would be:

    docker push fastgenomics/fancy_shiny:1.0

    Please note that depending on your internet connection and the image size this can take a while. Alternatively, after testing you can also use automated builds on Docker Hub directly.

  8. Create an analysis using your new image on FASTGenomics. To use your new Shiny app in FASTGenomics, create a new analysis with your own image as described here.

Further Notes

  • Try to keep the Images size as small as possible. In the free-to-use version of FASTGenomics, the images has top be pulled from Docker Hub every time it is started. The bigger your image, the longer it takes. So if you modify the Dockerfile always try to clean temporary files in each layer.
  • FASTGenomics can only use images that are publicly available on Docker Hub. If you need a more private solution, please contact us via e-mail or Slack
  • If you need help with Docker, a good start are the official docker docs.
  • You are responsible for the content of your custom images.