Preserve R Shiny project structure when dockerizing app

Viewed 25

I have built a Shiny app with the following project structure:

->Dockerfile  
->install_packages.R  
->app (Folder) 
->app/global.R  
->app/ui.R  
->app/server.R  
->app/R (Folder)  
->app/R/Folder A with further subfolders with server/ui scripts  
->app/R/Folder B with further subfolders with server/ui scripts 

When I run the script as a Shiny app, I call in global.R files, which are in the subfolders, e.g.

source("R/Folder A/MyScript_UI.R") 

When I dockerize the app (Dockerfile below), the folder structure is "gone" (?) and I need to call the files by

source("Folder A/MyScript_UI.R")  

This is of course highly inconvenient, as I would need to develop the app with source("R/...) and when deploying, delete the "R/". What am I doing wrong?

Dockerfile:

FROM rocker/shiny:latest

RUN apt-get update && apt-get install -y --no-install-recommends \
    sudo \
    pandoc \
    pandoc-citeproc \
    libcurl4-gnutls-dev \
    libcairo2-dev \
    libxt-dev \
    libssl-dev \
    libssh2-1-dev \
      libxml2 \
      libglu1-mesa\
    && rm -rf /var/lib/apt/lists/*

COPY install_packages.R /install_packages.R

RUN Rscript /install_packages.R

COPY ./app/* /home/app/

EXPOSE 3838

CMD ["R", "-e", "shiny::runApp('/home/app', host = '0.0.0.0', port = 3838)"]
1 Answers
Related