我正在尝试为我的R脚本创建一个Docker镜像,以便在Google Cloud上调度R作业。我正在用一个小的R脚本测试它。docker build
命令在我安装rga
GitHub包的步骤中失败。下面是我的R脚本和DockerFile:
R脚本:
library(rga)
library(bigrquery)
bq_token()
rga.open(instance = "ga", where="~/ga.rga")
demoScheduleAPI <- function(){
search_perf <- ga$getData(XXXX, batch = TRUE, walk = TRUE,
start.date = "2020-01-15",
end.date = "2020-01-16",
metrics = "ga:searchUniques",
dimensions="ga:date,ga:hour,ga:searchKeyword, ga:searchCategory ,ga:dimension6,ga:dimension10")
project <- "bidone-data"
insert_upload_job(project, "GA_Export_Prod_DataSet", "Test_Table123", search_perf)
}
Dockerfile
FROM rocker/r-ver:3.6.1
RUN mkdir /home/bidone
RUN R -e "install.packages('bigrquery', repos='http://cran.rstudio.com/')"
RUN R -e "install.packages('devtools', repos='http://cloud.r-project.org')"
RUN R -e "devtools::install_github('skardhamar/rga')"
COPY .secrets /home/analysis/.secrets
COPY ga /home/analysis/ga
COPY DockerTest.R /home/analysis/DOckerTest.R
CMD R -e "source('/home/analysis/DockerTest.R')"
它确实安装了devtools包,但是当它试图从github安装rga
包时,它给出了以下错误。
> devtools::install_github('skardhamar/rga')
Error in loadNamespace(name) : there is no package called ‘devtools’
Calls: :: ... loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
Execution halted
The command '/bin/sh -c R -e "devtools::install_github('skardhamar/rga')"' returned a non-zero code: 1
如何解决此问题?
1条答案
按热度按时间nbysray51#
你最好的选择是GitHub搜索。下面是我的一个例子,用于支持class I teach的容器,构建在another Dockerfile from our Rocker Project上。该链接为您提供了完整的细节,但为了简洁起见,我们在这里省略了一些位
这基本上涵盖了我们
install.r
从CRAN安装一些软件包installGithub.r
从GitHub安装另外两个仓库这只是显示了我的首选排序:二进制文件超过CRAN超过GitHub。你的问题的关键点是,这些littler脚本也在R-ver堆栈上。但是对于r-ver,你必须 * 非常小心 * 混合,因为发布日期是通过设计 * 固定在MRAN上的。
(And如果有人想知道更多关于这个容器的原因,我们只放一个pre-print on arXiv--但这是我们使用的测试和分级基础设施的特定内容。