Skip to content
Snippets Groups Projects
Commit eba6588a authored by echapeau's avatar echapeau
Browse files

update Readme file since dedicated branch created

parent 0800cb10
No related branches found
No related tags found
No related merge requests found
Pipeline #103074 passed
Pipeline: shiny-k8s-example

#103075

    # rshiny-k8s # rshiny-k8s
    ## Aim of the project ## Project Goal
    Help hub members to deploy correctly and easily an Web application, initially developed in RShiny, under Kubernetes. To help hub members to correctly and easily deploy a web application, initially developed in RShiny, under Kubernetes .
    ## Workflow You are in one of the gitlab projects dedicated to Rshiny application deployment under Kubernetes :**"rshiny-k8s".**
    This workflow described all steps to follow in order to deploy your app under kubernetes available at Institut Pasteur - Paris. ## Project structure and dependencies
    Today,
    1. Develop your shiny app
    2. Create a docker image
    3. Init the deployement under gitlab
    4. Configure your deployement under kubernetes.
    ### Step 1. Develop your shiny app
    Create your shiny app by following the basic best practices like using multiple files (ui.R, server.R and global.R) and save files on gitlab project.
    Your are free to develop your app as you want. The only constraint is to list the requiered packages.
    List all the packages needed by your application in an dedicated file - named "packages_to_install.csv" respecting the following structure :
    ---> Name of the package;Name of the repository where the package will be found
    ```console
    Package_name;Deposit_name
    shiny;cran
    dplyr;cran
    affy;bioconductor
    ...
    ```
    Be carefull not to put any space character at the end of word.
    This file will be used by the dockerfile in order to install all packages on the shiny server.
    ### Step 2. Create a docker image
    The purpose of the docker image is to create a proper environment where your Shiny application will be hosted. Your application will be containerized. This tutorial is divided into several gitlab projects:
    - project named **"rshiny-k8s"** : For the developer, the co For the developer, the configuration files and templates to build the initial docker image and CI configuration ( /.gitlab-ci.yml ) .
    - project named **"rshiny-k8s"** special branch ["docs"](https://gitlab.pasteur.fr/hub/rshiny-k8s/-/tree/docs) : For Developer, branch dedicated to write the complete documentation under sphinx (available on https://hub.pages.pasteur.fr/rshiny-k8s/)
    - project named ["rshiny-k8s-example"](https://gitlab.pasteur.fr/hub/rshiny-k8s-example) : For Developper, configuration and template files for deployment under kubernetes with (chart folder) or without helm (k8s folder)
    Contains only a simple example of Shiny application.
    The image used is based on the previous image created in the "rshiny-k8s" project
    This container will contain: In the future:
    - an Ubuntu Linux system with R installed
    - a shiny server (not the professional version)
    - your app
    All these requirements are listed in a dedicated file named "Dockefile". This tutorial is divided into several gitlab projects:
    - project named **"rshiny-k8s"** : For the developer, the configuration files and template to build the initial docker image and CI configuration ( /.gitlab-ci.yml ) .
    - project named **"rshiny-k8s"** special branch ["docs"](https://gitlab.pasteur.fr/hub/rshiny-k8s/-/tree/docs) : For Developer, branch dedicated to write the complete documentation under sphinx (available on https://hub.pages.pasteur.fr/rshiny-k8s/)
    - project named "rshiny-k8s-helm" : For Developper, configuration files and template in helm for deployment under kubernetes
    - project named ["rshiny-k8s-example"](https://gitlab.pasteur.fr/hub/rshiny-k8s-example): For user only, with simplified configuration files and a template to "deploy" your Shiny application on the kube.
    Contains several examples of Shiny application templates
    The image used is based on the previous image created in the "rshiny-k8s" project
    Use the Helm configuration of the "rshiny-k8s-helm" project
    In this file, you only need to indicate the folder name of your application. Replace "MyAppName" with the correct name. ## Workflows
    ### for Developer
    ```python 1. Create a basic docker image with R and Shiny Server
    FROM rocker/shiny:latest 2. Create a docker image, based on the previous one, with Rshiny application and R packages needed
    USER root 3. Initiate the deployement under gitlab with CI configuration
    # delete previous exemples on shiny-server 4. Configure the deployement under kubernetes
    RUN rm -rf /srv/shiny-server/* 5. Configure the deployement under kubernetes with helm
    # change permission for user shiny 6. Deploy the application using your previous recipe
    RUN sudo chown -R shiny:shiny /usr/local/lib/R/etc/
    ## Install R packages from CRAN or bioconductor
    COPY ./script_r_to_docker/script_install_r_packages.R .
    COPY ./script_r_to_docker/packages_to_install.csv .
    RUN Rscript script_install_r_packages.R
    WORKDIR /srv/shiny-server/
    # copy the app directory into the image
    COPY ./MyAppName/. /srv/shiny-server/MyAppName/
    USER shiny
    CMD ["/usr/bin/shiny-server"]
    ```
    # Troubleshooting, dev cheat sheet
    Build the image, and run it
    ```sh
    docker build . -t rshiny-k8s-test
    docker run -it -p 3838:3838 rshiny-k8s-test
    ```
    To locally run the server
    ```sh
    docker build . -t rshiny-k8s-test
    docker run --rm -ti -v $(pwd)/example_proj:/srv/shiny-server --user shiny -p 3838:3838 rocker/shiny
    docker run --rm -ti -v $(pwd)/example_proj:/srv/shiny-server -p 3838:3838 rocker/shiny
    ```
    ### for RShiny Application Developer
    This workflow described all steps to follow in order to deploy your app under kubernetes available at Institut Pasteur - Paris.
    1. Develop your shiny app
    2. Containerize your Shiny app
    3. Deployement your application under kubernetes
    ## Documentation
    More information, see [Documentation](https://hub.pages.pasteur.fr/rshiny-k8s/)
    \ No newline at end of file
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment