我对 RShiny、Golem 和 Docker 比较陌生。但是,我已经使用 Golem 框架构建了一个小型分析仪表板,我想使用 Docker 在本地部署它。
我已经能够成功构建映像,但似乎无法让容器正常运行。当我这样做时,容器初始化然后停止并出现以下错误:
> options('shiny.port'=80,shiny.host='0.0.0.0');ShinyPlatform::run_app()
Error in loadNamespace(x) : there is no package called ‘ShinyPlatform’
Calls: loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
Execution halted
如果有任何帮助,我用来运行的命令如下:
docker run shinytest2
我也在与 Rshiny 应用程序相关的项目文件夹中工作(不知道这是否有帮助)。
细节是它使用 renv 和 golem 框架,以及 CRAN 和本地包的混合。下面是我目前正在使用的 dockerfile,其中大部分是使用golem::add_dockerfile()
. 我修改的唯一行如下:
RUN R -e 'install.packages("renv/local/LocalPackage1_0.1.0.tar.gz", repos= NULL, type = "source")'
RUN R -e 'install.packages("renv/local/ShinyPlatform_0.0.0.9000.tar.gz", repos = NULL, type = "source")'
上面的第一个是为了解决由于 LocalPackage1 被放置在另一个文件夹中而找不到的错误。第二行更像是我尝试的尝试,看看我是否可以做同样的事情来解决当前的错误,到目前为止还没有这样的运气,所以我很确定这是错误的。
这是整个 docker 文件:
FROM rocker/r-ver:4.1.1
RUN apt-get update && apt-get install -y git-core libcairo2-dev libcurl4-openssl-dev libgit2-dev libicu-dev libssl-dev libxml2-dev make pandoc pandoc-citeproc zlib1g-dev && rm -rf /var/lib/apt/lists/*
RUN echo "options(repos = c(CRAN = 'https://cran.rstudio.com/'), download.file.method = 'libcurl', Ncpus = 4)" >> /usr/local/lib/R/etc/Rprofile.site
RUN R -e 'install.packages("remotes")'
RUN Rscript -e 'remotes::install_version("magrittr",upgrade="never", version = "2.0.1")'
RUN Rscript -e 'remotes::install_version("glue",upgrade="never", version = "1.4.2")'
RUN Rscript -e 'remotes::install_version("processx",upgrade="never", version = "3.5.2")'
RUN Rscript -e 'remotes::install_version("testthat",upgrade="never", version = "3.1.0")'
RUN Rscript -e 'remotes::install_version("htmltools",upgrade="never", version = "0.5.2")'
RUN Rscript -e 'remotes::install_version("attempt",upgrade="never", version = "0.3.1")'
RUN Rscript -e 'remotes::install_version("shiny",upgrade="never", version = "1.7.1")'
RUN Rscript -e 'remotes::install_version("config",upgrade="never", version = "0.3.1")'
RUN Rscript -e 'remotes::install_version("spelling",upgrade="never", version = "2.2")'
RUN Rscript -e 'remotes::install_version("thinkr",upgrade="never", version = "0.15")'
RUN Rscript -e 'remotes::install_version("shinyWidgets",upgrade="never", version = "0.6.2")'
RUN Rscript -e 'remotes::install_version("shinydashboard",upgrade="never", version = "0.7.2")'
RUN Rscript -e 'remotes::install_version("renv",upgrade="never", version = "0.14.0")'
RUN Rscript -e 'remotes::install_version("readxl",upgrade="never", version = "1.3.1")'
RUN Rscript -e 'remotes::install_version("gt",upgrade="never", version = "0.3.1")'
RUN Rscript -e 'remotes::install_version("golem",upgrade="never", version = "0.3.1")'
RUN R -e 'install.packages("renv/local/LocalPackage1_0.1.0.tar.gz", repos= NULL, type = "source")'
RUN R -e 'install.packages("renv/local/ShinyPlatform_0.0.0.9000.tar.gz", repos = NULL, type = "source")'
RUN Rscript -e 'remotes::install_version("DT",upgrade="never", version = "0.19")'
RUN Rscript -e 'remotes::install_version("DBI",upgrade="never", version = "1.1.1")'
RUN Rscript -e 'remotes::install_version("data.table",upgrade="never", version = "1.14.0")'
RUN echo "options(repos = c(CRAN = 'https://cran.rstudio.com/'), download.file.method = 'libcurl', Ncpus = 4)" >> /usr/local/lib/R/etc/Rprofile.site
RUN mkdir /build_zone
ADD . /build_zone
WORKDIR /build_zone
RUN rm -rf /build_zone
EXPOSE 80
CMD R -e "options('shiny.port'=80,shiny.host='0.0.0.0');ShinyPlatform::run_app()"
想知道是否有人对为什么我的容器停止并且似乎无法在其中找到闪亮的应用程序有任何想法?
如前所述,我对 RShiny、Golem 和 Docker 都很陌生,所以如果我遗漏了任何关键信息,请告诉我,我可以更新这篇文章。