我一直在使用 Golem 框架来构建 R Shiny 应用程序,这非常有用,但我在框架的 docker 文件创建方面遇到了困难。
工作流程:
在 RStudio 中,我创建了一个新的 golem 包,并插入了 MIT 许可证(没有许可证我在 devtools::check() 中收到警告)
Run devtools::check() # Check pass no error no warnings
运行 golem::add_dockerfile() # 在项目根目录中创建一个 Dockerfile
关闭 RStudio 并在 VScode 中打开文件夹(docker build 通过 RStudio 失败)
泊坞窗构建 -t 测试。
docker run --rm -p 3838:3838 测试
我现在看到以下控制台输出
R version 4.1.0 (2021-05-18) -- "Camp Pontanezen"
Copyright (C) 2021 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> options('shiny.port'=80,shiny.host='0.0.0.0');experimentdocker::run_app()
Loading required package: shiny
Listening on http://0.0.0.0:80
但是当我导航到http://0.0.0.0:80时,我看到“此页面现在无法正常工作”
我真的很感激可以提供的任何支持。
我在下面包含了标准的 golem dockerfile。
FROM rocker/r-ver:4.1.0
RUN apt-get update && apt-get install -y git-core libcurl4-openssl-dev libgit2-dev libicu-dev libssl-dev libxml2-dev make pandoc pandoc-citeproc && 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("shiny",upgrade="never", version = "1.6.0")'
RUN Rscript -e 'remotes::install_version("config",upgrade="never", version = "0.3.1")'
RUN Rscript -e 'remotes::install_version("golem",upgrade="never", version = "0.3.1")'
RUN mkdir /build_zone
ADD . /build_zone
WORKDIR /build_zone
RUN R -e 'remotes::install_local(upgrade="never")'
RUN rm -rf /build_zone
EXPOSE 80
CMD R -e "options('shiny.port'=80,shiny.host='0.0.0.0');experimentdocker::run_app()"