Skip to contents

Introduction

Shiny apps are great for using R interactively. Nevertheless, each app uses different packages and/or package versions or even different R versions. To save users from constantly installing the required versions for a specific Shiny app, developers can opt for ShinyProxy to deploy their application on a Shiny Server. Each app then becomes a docker image with its own set of packages and every time a user launches the app, a container from the image is spawn from the appropriate image.

Dockerization

  1. Makes sure that no folder deploy exists at the project root.

  2. Follow steps in dev/03_deploy.R, namely:

Note: dockerfiler is needed ( uses pak).

devtools::check()
devtools::build()
golem::add_dockerfile_with_renv_shinyproxy(output_dir = "deploy", lockfile = "renv.lock")
# if renv.lock.prod is missing
attachment::create_renv_for_prod()
file.copy("renv.lock.prod", "deploy/renv.lock.prod")
  1. Should obtain a README in deploy that is:
docker build -f Dockerfile_base --progress=plain -t flowfate_base .
docker build -f Dockerfile --progress=plain -t flowfate:latest .
docker run -p 3838:3838 flowfate:latest
# then go to 127.0.0.1:3838

deploy folder contains:

Dockerfile
Dockerfile_base
flowFate_0.1.0.tar.gz
README
renv.lock
renv.lock.prod
  1. scp the deploy folder to the `shiny-sever` in the shinyproxy container_apps/ and execute as root the commands in the README

Make sure to use the binary versions for Linux from PPPM

RUN R -e "renv::restore(repos = 'https://packagemanager.posit.co/cran/__linux__/jammy/latest/')"

docker build -f Dockerfile_base --progress=plain -t flowfate_base .
docker build -f Dockerfile --progress=plain -t flowfate:latest .
  1. edit ~/deploiement/container_system/shinyproxy-docker/application.yml

adding something like:

  - id: flowfate
    display-name: flowFate
    container-network: sp-network
    description: Application Flow Cytometry Gating Maxime Sünnen
    container-cmd: ["R", "-e", "library(flowFate);options('shiny.port'=3838,shiny.host='0.0.0.0');flowFate::run_app()"]
    container-image: flowfate
  1. In ~/deploiement/, run ./relance_machinerie so the new app is linked.