我正在尝试推出一款闪亮的应用程序,并使用docker。我有一个Dockerfile
和renv.lock
文件。构建扩展坞镜像不会出现任何错误,并且所有包都已安装,安装后会在终端中提示ok
。
运行停靠容器时,它会立即退出并提示错误:
* Project '/app' loaded. [renv 0.15.5]
> options(shiny.port=3838); rhino::app()
# Bootstrapping renv 0.15.5 --------------------------------------------------
* Downloading renv 0.15.5 ... OK (downloaded source)
* Installing renv 0.15.5 ... Done!
* Successfully installed and loaded renv 0.15.5.
Error in loadNamespace(x) : there is no package called ‘rhino’
Calls: loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
Execution halted
但是,包rhino
在renv.lock
文件中找到。
我已经两次尝试在没有缓存的情况下进行重建,但都没有帮助。使用renv::restore()
也没有帮助。
文档文件:
# Use R 4.2.0
FROM rocker/r-ver:4.2.0
# Install system libraries of general use
RUN apt-get update && apt-get install -y --no-install-recommends
sudo
libcurl4-gnutls-dev
libcairo2-dev
libxt-dev
libssl-dev
libssh2-1-dev
libpq-dev
libxml2-dev
&& rm -rf /var/lib/apt/lists/*
RUN R -e "install.packages('renv')"
# Set work dir
WORKDIR /app
COPY renv.lock renv.lock
# Restore all renv packages
RUN R -e 'renv::restore()'
# Copy project to image
COPY . .
# Expose port 3838
EXPOSE 3838
# Run app
CMD ["R", "-e", "options(shiny.port=3838); rhino::app()"]
# CMD ["R", "-e", "options(shiny.host='0.0.0.0'); options(shiny.port=3838); rhino::app()"]
# CMD ["R", "-e", "shiny::runApp('/home/app', host = getOption('shiny.host', '0.0.0.0'), port = 3838)"]
Renv.lock文件的片段(>1k行)
"rhino": {
"Package": "rhino",
"Version": "1.1.0",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "9db64442690b12f94ae73f6b561c9139",
"Requirements": [
"box",
"cli",
"config",
"fs",
"glue",
"lintr",
"logger",
"purrr",
"renv",
"rstudioapi",
"sass",
"shiny",
"styler",
"testthat",
"withr",
"yaml"
]
},
1条答案
按热度按时间jpfvwuh41#
你能解决这个问题吗。我也遇到了同样的问题。