Reputation: 60
I have the following dockfile
# 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 -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
## update system libraries
RUN apt-get update && \
apt-get upgrade -y && \
apt-get clean
# copy necessary files
## app folder
COPY ./app ./app
# 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))'
# 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("shinydashboardPlus")'
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("forecast", dependencies = TRUE)'
RUN Rscript -e 'install.packages("tsutils")'
RUN Rscript -e 'install.packages("readxl")'
RUN Rscript -e 'install.packages("tidyverse")'
RUN Rscript -e 'install.packages("knitr")'
RUN Rscript -e 'install.packages("knitcitations")'
RUN Rscript -e 'install.packages("nycflights13")'
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("cowplot")'
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("BiocManager")'
#RUN R -e 'BiocManager::install("rtracklayer")'
#RUN R -e 'BiocManager::install("GenomicAlignments")'
#RUN R -e 'BiocManager::install("Biostrings")'
#RUN R -e 'BiocManager::install("SummarizedExperiment")'
#RUN R -e 'BiocManager::install("Rsamtools")'
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("Marlin-Na/trewjb")'
RUN Rscript -e 'devtools::install_github("dirkschumacher/ompr")'
RUN Rscript -e 'devtools::install_github("dirkschumacher/ompr.roi")'
RUN Rscript -e 'install.packages("ROI.plugin.glpk")'
RUN Rscript -e 'install.packages("shinydashboard")'
RUN Rscript -e 'install.packages("dplyr")'
RUN Rscript -e 'install.packages("dashboardthemes")'
RUN Rscript -e 'install.packages("shinyjs")'
RUN Rscript -e 'install.packages("magrittr")'
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 3838
# run app on container start
CMD ["R", "-e", "shiny::runApp('/app', host = '0.0.0.0', port = 3838)"]
When I try to upload without Bioconductor packages the app running But when I am trying to upload as the dockfile is I receive the following error.
Bioconductor version 3.12 (BiocManager 1.30.10), ?BiocManager::install for help shiny::runApp('/app', host = '0.0.0.0', port = 3838) Error in shinyAppDir(x) : No Shiny application exists at the path "/app" Calls: ... as.shiny.appobj -> as.shiny.appobj.character -> shinyAppDir Execution halted
I visit some solution but I do not understand them....please I need your help
Upvotes: 0
Views: 174
Reputation: 2016
Check out the docs on multistage builds
You have a COPY statement, and right after that a FROM statement. After that last statement you no longer have access to whatever was in there in previous stage. You can copy files from one stage to the next if needed with --from=stagename
where you named the stage with FROM somerepo/someimage as stagename
.
In this case it means that everything you do in the first stage is never used or available again.
Normally this is used something like
FROM baseimage as build
RUN install some dependencies
COPY some sourcefiles
RUN install stuff eg mvn install
FROM runImage as run
COPY --from=build somepath/executable
CMD ["do", "something"]
This way you keep the final image small, removing everything you need at build time, but not at runtime. In your case you have to rethink this a bit and see what you need at which stage.
I do not know the specifics of your app but the way you have it set up now is that you start with a base image, then install debian suff, then system stuff and then start all over with a "empty" new baseimage. You probably want to use just one image and go from there, with just one FROM
instruction. Then if you want to optimize it for production you can always consider the multistage build if that is worth it in your case.
Upvotes: 1