0

Good afternoon to everybody. I deployed a shiny app in Docker. I need Bioconductor packages/ I find the way and the app working properly. But now I've got shown that is very big size the app. probably this is due to 2 layers ( 1 of the app and 1 of the Bioconductor packages.) I have read also that I must remove the second docker layer and try to install Bioconductor on the rocker/shiny image. But I do not know how to realize that information. I attach the dockerfile. Does anybody have idea please to make lighter the app in docker?

# Base image https://hub.docker.com/u/rocker/
FROM rocker/shiny:latest

# system libraries of general use
## install debian packages
RUN apt-get update -qq && \
    apt-get upgrade -y && \
    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 \
    coinor-libcbc-dev coinor-libclp-dev libglpk-dev && \
    apt-get clean


# Docker inheritance
FROM bioconductor/bioconductor_docker:RELEASE_3_12
RUN apt-get update
    RUN R -e 'BiocManager::install(ask = F)' && R -e 'BiocManager::install(c("rtracklayer", \
    "GenomicAlignments", "Biostrings", "SummarizedExperiment", "Rsamtools", ask = F))'


# copy necessary files
## app folder
COPY ./folder ./app

# install renv & restore packages
RUN Rscript -e 'install.packages("renv")'
RUN Rscript -e 'install.packages("devtools")'
RUN Rscript -e 'install.packages("shiny")'
RUN Rscript -e 'install.packages("shinyBS")'
RUN Rscript -e 'install.packages("ggvis")'
RUN Rscript -e 'install.packages("shinycssloaders")'
RUN Rscript -e 'install.packages("shinyWidgets")'
RUN Rscript -e 'install.packages("plotly")'
RUN Rscript -e 'install.packages("RSQLite")'
RUN Rscript -e 'install.packages("knitr")'
RUN Rscript -e 'install.packages("knitcitations")'
RUN Rscript -e 'install.packages("Matrix")'
RUN Rscript -e 'install.packages("plotly")'
RUN Rscript -e 'install.packages("igraph")'
RUN Rscript -e 'install.packages("ggthemes")'
RUN Rscript -e 'install.packages("evaluate")'
RUN Rscript -e 'install.packages("psych")'
RUN Rscript -e 'install.packages("kableExtra")'
RUN Rscript -e 'install.packages("ggjoy")'
RUN Rscript -e 'install.packages("gtools")'
RUN Rscript -e 'install.packages("gridExtra")'
RUN Rscript -e 'install.packages("ggrepel")'
RUN Rscript -e 'install.packages("data.table")'
RUN Rscript -e 'install.packages("stringr")'
RUN Rscript -e 'install.packages("rmarkdown")'
RUN Rscript -e 'install.packages("shinyjqui")'
RUN Rscript -e 'install.packages("V8")'
RUN Rscript -e 'devtools::install_github("ThomasSiegmund/D3TableFilter")'
RUN Rscript -e 'devtools::install_github("leonawicz/apputils")'

RUN Rscript -e 'devtools::install_github("dirkschumacher/ompr")'
RUN Rscript -e 'devtools::install_github("dirkschumacher/ompr.roi")'
RUN Rscript -e 'install.packages("shinydashboard")'
RUN Rscript -e 'install.packages("dplyr")'
RUN Rscript -e 'install.packages("shinyjs")'
RUN Rscript -e 'install.packages("DT")'
RUN Rscript -e 'install.packages("rhandsontable")'
RUN Rscript -e 'renv::consent(provided = TRUE)'
RUN Rscript -e 'renv::restore()'


# expose port
EXPOSE 8080

# run app on container start
CMD ["R", "-e", "shiny::runApp('/app', host = '0.0.0.0', port = 8080)"]
Adam
  • 60
  • 7
  • 1
    (1) I might be mistaken, but I think each `RUN` creates a new docker filesystem layer. Try to combine them into fewer `RUN` lines. (2) `docker` (version 1.13 and later) should support `docker build --squash` (if the docker daemon has experimental features enabled). If not that, then (3) perhaps `docker export img | docker import - img:new`. See https://stackoverflow.com/a/22714556/3358272 and https://geekthis.net/post/docker-reduce-size/. – r2evans Jan 26 '21 at 21:02
  • More thoughts: you run `apt-get update` but never install any os-level packages; is that required for bioconductor? Regardless, you can reduce some image size by purging some `apt` caches, including `/var/lib/apt/lists` and `/var/cache/apt/archives/` (though the latter *may* be auto-cleaned on each install, c.f., https://github.com/rocker-org/rocker/issues/35#issuecomment-58944297). – r2evans Jan 26 '21 at 21:07
  • 1
    Thank you very much. I used squash option and is true that create me an single layer. Seems that the app is faster. In general I accept ideas to make faster apps in Docker.Thank you – Adam Jan 27 '21 at 12:39
  • You might want to check [r-minimal](https://github.com/r-hub/r-minimal). – ismirsehregal Jul 23 '21 at 12:59

0 Answers0