【发布时间】:2019-08-17 02:56:01
【问题描述】:
我正在编写一个 Dockerfile 来创建一个基于 rocker/verse:3.6.1 的 docker 映像。我需要安装 Github 上可用的 R 包,并且我需要安装来自特定提交的每个包。 我正在使用具有以下内容的 Dockerfile:
FROM rocker/verse:3.6.1
LABEL maintainer='Unknown'
RUN R -e "devtools::install_github('rstudio/renv', ref = '1584b7fccb49c2bd502ea4bdf3b7de27b0243561')"
在包含此 Dockerfile 的目录中,在 shell 提示符下输入 docker build . 后,我看到了以下输出。
docker build .
Sending build context to Docker daemon 2.048kB
Step 1/3 : FROM rocker/verse:3.6.1
---> 8a978a45abab
Step 2/3 : LABEL maintainer='Unknown'
---> Using cache
---> d054ca33baac
Step 3/3 : RUN R -e "devtools::install_github('rstudio/renv', ref = '1584b7fccb49c2bd502ea4bdf3b7de27b0243561')"
---> Running in dea49b1bb351
R version 3.6.1 (2019-07-05) -- "Action of the Toes"
Copyright (C) 2019 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.
> devtools::install_github('rstudio/renv', ref = '1584b7fccb49c2bd502ea4bdf3b7de27b0243561')
Error: Failed to install 'unknown package' from GitHub:
HTTP error 404.
No commit found for the ref 1584b7fccb49c2bd502ea4bdf3b7de27b0243561
Did you spell the repo owner (`rstudio`) and repo name (`renv`) correctly?
- If spelling is correct, check that you have the required permissions to access the repo.
Execution halted
The command '/bin/sh -c R -e "devtools::install_github('rstudio/renv', ref = '1584b7fccb49c2bd502ea4bdf3b7de27b0243561')"' returned a non-zero code: 1
在不使用 docker 时,我通过进入 shell 成功安装了所需的包(在所需的提交处)
R -e "devtools::install_github('rstudio/renv', ref = '1584b7fccb49c2bd502ea4bdf3b7de27b0243561')"
我也可以用这个 Dockerfile 成功构建一个 docker 镜像:
FROM rocker/verse:3.6.1
LABEL maintainer='Unknown'
RUN R -e "devtools::install_github('rstudio/renv')"
我省略了参数ref 的显式包含。但是,我仍在努力构建我需要的图像。
感谢您对这些观察结果的任何解决方案和解释。
PS - 这是我用来识别提交哈希的 R 代码:
github_lookup_commit_sha_and_date <- function(remote_pkg, date, limit = 1000){
commits_list <- gh::gh(paste0("/repos/", remote_pkg, "/commits"), .limit = limit)
commit_dates <- purrr::map(.x = commits_list, .f = function(x) lubridate::as_datetime(x$commit$author$date))
commit_shas <- purrr::map_chr(.x = commits_list, .f = function(x)x$commit$tree$sha)
tibble::tibble(commit_date = lubridate::as_datetime(unlist(commit_dates)), sha = commit_shas) %>%
dplyr::filter(commit_date < as_datetime(date)) %>%
dplyr::mutate(datetime_diff = abs(commit_date - as_datetime(date)), remote_package = remote_pkg) %>%
dplyr::filter(datetime_diff == min(datetime_diff))
}
github_lookup_commit_sha_and_date("rstudio/renv", lubridate::as_date("2019-01-01"))
PPS - 这是我在 docker 外部安装 rstudio/renv 时看到的输出。
> devtools::install_github('rstudio/renv', ref = '1584b7fccb49c2bd502ea4bdf3b7de27b0243561')
Downloading GitHub repo rstudio/renv@1584b7fccb49c2bd502ea4bdf3b7de27b0243561
✔ checking for file ‘/private/var/folders/wd/lxmyvz590xb81c5z1j88b3800000gn/T/RtmpNW1W3J/remotesc63521cc2a5d/rstudio-renv-1584b7f/DESCRIPTION’ ...
─ preparing ‘renv’:
✔ checking DESCRIPTION meta-information ...
─ checking for LF line-endings in source and make files and shell scripts
─ checking for empty or unneeded directories
─ building ‘renv_0.0.1-42.tar.gz’
* installing *source* package ‘renv’ ...
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (renv)
【问题讨论】:
-
可以以某种方式缓存您的哈希吗?
checking for file ‘/private/var/folders/wd/lxmyvz590xb81c5z1j88b3800000gn/T/RtmpNW1W3J -
我想这是可能的。您能否建议我如何知道它是否在本地缓存?
标签: r docker github dockerfile devtools