'Getting Docker run error File does not exist or is non-readable. getwd()=='/'?

I got error related to reading file when I run docker run ..., while the shiny app works well in Rstudio.

All data (Input tables), shiny app .R file and Docker file are in the same folder.

First line of shiny app that I got error in docker run:

gene<-data.frame(data.table::fread('PCR_Gene_CP.GZ.csv'))

and Docker file is:

# get shiny packages image
FROM rocker/shiny:latest

#system libraries of general use
## install debian packages
RUN apt-get update -qq && apt-get -y --no-install-recommends install libxml2-dev libcairo2-dev 
libsqlite3-dev libmariadbd-dev libpq-dev libssh2-1-dev unixodbc-dev libcurl4-openssl-dev libssl-dev

## update system libraries
RUN apt-get update && apt-get upgrade -y && apt-get clean

# install R packages required 
# (change it dependeing on the packages you need)
RUN R -e "install.packages(pkgs=c('shiny','ggplot2','data.table','DT','dplyr','tidyr','tibble','VennDiagram'), repos='http://cran.rstudio.com/')"

COPY /app.R /app.R

# expose port
EXPOSE 3838

# run app on container start
CMD ["R", "-e", "shiny::runApp('/app.R', host = '0.0.0.0', port = 3838)"]

Running Docker build,run and logs:

docker build -t enhancer .
docker run -p 8081:3838 --name enhancer -d enhancer

docker logs -t enhancer

enter image description here



Solution 1:[1]

Instead of triggering TypeChar() method in fixed update, you can convert TypeChar() to a Coroutine that can handle time more performing way.

 private IEnumerator TypeChar()
 {
     while(sentenceIndex >= charSentence.Length) 
     {
        if(typeSentence)
        {
            GUIs[dialogue.UIIndex].dialogueText.text += charSentence[sentenceIndex];
            sentenceIndex++;
            yield return new WaitForSeconds(charDelay);
        }
     }
     typeSentence = false;
     sentenceIndex = 0;
     GUIs[dialogue.UIIndex].continueButton.SetActive(true); 
 }

And you can delete typeSentence variable completely if you do not change it out of scope.

And you can call it at Start instead of FixedUpdate.

private void Start()
{
    StartCoroutine(nameof(TypeChar));
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1