Docker 在 Jenkins 上构建很慢
Docker build is slow on Jenkins
我正在尝试通过 Jenkins 管道构建一个 docker 图像,这需要很长时间(4-5 小时,而且大部分时间都失败了)。当我从同一台 Jenkins 机器的命令行构建图像时,大约需要 20 分钟。这些是作业停止的 Dockerfile 命令 -
ARG PKGS="askpass, assertthat, backports, base64enc, BH, bit, bit64, blob, brew, brio, broom, callr, caret, cellranger, chron, cli, clipr, colorspace, commonmark, config, covr, cpp11, crayon, credentials, crosstalk, curl, data.table, DBI, dbplyr, desc, devtools, diffobj, digest, dplyr, DT, ellipsis, evaluate, fansi, farver, fastmap, forcats, foreach, forge, fs, future, generics, gert, ggplot2, gh, gitcreds, glmnet, globals, glue, gower, gridExtra, gsubfn, gtable, haven, highr, hms, htmlwidgets, httpuv, httr, ini, ipred, isoband, iterators, jsonlite, knitr, labeling, later, lava, lazyeval, lifecycle, listenv, lubridate, magrittr, markdown, memoise, mime, ModelMetrics, modelr, munsell, numDeriv, openssl, parallelly, pillar, pkgbuild, pkgconfig, pkgload, plogr, plyr, praise, prettyunits, pROC, processx, prodlim, progress, promises, proto, ps, purrr, r2d3, R6, randomForest, rappdirs, rcmdcheck, RColorBrewer, Rcpp, readxl"
# Install through pak and other cleanup tasks
RUN Rscript -e 'install.packages("pak", repos = "https://r-lib.github.io/p/pak/dev/")' \
&& echo "$PKGS" \
| Rscript -e 'pak::pkg_install(strsplit(readLines("stdin"), ", ?")[[1L]], ask = FALSE)' \
&& Rscript -e 'pak::cache_clean()'
ARG PKGS="recipes, rematch, rematch2, remotes, reprex, reshape2, rex, rlang, rmarkdown, roxygen2, rprojroot, RSQLite, rstudioapi, rversions, rvest, scales, selectr, sessioninfo, shape, shiny, sourcetools, sparklyr, SparkR, sqldf, SQUAREM, stringi, stringr, sys, testthat, tibble, tidyr, tidyselect, tidyverse, timeDate, tinytex, usethis, utf8, uuid, vctrs, viridisLite, waldo, whisker, withr, xfun, xml2, xopen, xtable, yaml, zip"
# Install through pak and other cleanup tasks
RUN Rscript -e 'install.packages("pak", repos = "https://r-lib.github.io/p/pak/dev/")' \
&& echo "$PKGS" \
| Rscript -e 'pak::pkg_install(strsplit(readLines("stdin"), ", ?")[[1L]], ask = FALSE)' \
&& Rscript -e 'pak::cache_clean()'
我怀疑这与 Jenkins 有关,因为构建从命令行运行良好。 Jenkins 中是否有某些设置会减慢这些软件包的下载和安装速度?谢谢。
想通了,需要用前面的 \ 转义 $ 字符,这样它就不会被计算。基本上将 "$PKGS"
替换为 "\$PKGS"
.
我正在尝试通过 Jenkins 管道构建一个 docker 图像,这需要很长时间(4-5 小时,而且大部分时间都失败了)。当我从同一台 Jenkins 机器的命令行构建图像时,大约需要 20 分钟。这些是作业停止的 Dockerfile 命令 -
ARG PKGS="askpass, assertthat, backports, base64enc, BH, bit, bit64, blob, brew, brio, broom, callr, caret, cellranger, chron, cli, clipr, colorspace, commonmark, config, covr, cpp11, crayon, credentials, crosstalk, curl, data.table, DBI, dbplyr, desc, devtools, diffobj, digest, dplyr, DT, ellipsis, evaluate, fansi, farver, fastmap, forcats, foreach, forge, fs, future, generics, gert, ggplot2, gh, gitcreds, glmnet, globals, glue, gower, gridExtra, gsubfn, gtable, haven, highr, hms, htmlwidgets, httpuv, httr, ini, ipred, isoband, iterators, jsonlite, knitr, labeling, later, lava, lazyeval, lifecycle, listenv, lubridate, magrittr, markdown, memoise, mime, ModelMetrics, modelr, munsell, numDeriv, openssl, parallelly, pillar, pkgbuild, pkgconfig, pkgload, plogr, plyr, praise, prettyunits, pROC, processx, prodlim, progress, promises, proto, ps, purrr, r2d3, R6, randomForest, rappdirs, rcmdcheck, RColorBrewer, Rcpp, readxl"
# Install through pak and other cleanup tasks
RUN Rscript -e 'install.packages("pak", repos = "https://r-lib.github.io/p/pak/dev/")' \
&& echo "$PKGS" \
| Rscript -e 'pak::pkg_install(strsplit(readLines("stdin"), ", ?")[[1L]], ask = FALSE)' \
&& Rscript -e 'pak::cache_clean()'
ARG PKGS="recipes, rematch, rematch2, remotes, reprex, reshape2, rex, rlang, rmarkdown, roxygen2, rprojroot, RSQLite, rstudioapi, rversions, rvest, scales, selectr, sessioninfo, shape, shiny, sourcetools, sparklyr, SparkR, sqldf, SQUAREM, stringi, stringr, sys, testthat, tibble, tidyr, tidyselect, tidyverse, timeDate, tinytex, usethis, utf8, uuid, vctrs, viridisLite, waldo, whisker, withr, xfun, xml2, xopen, xtable, yaml, zip"
# Install through pak and other cleanup tasks
RUN Rscript -e 'install.packages("pak", repos = "https://r-lib.github.io/p/pak/dev/")' \
&& echo "$PKGS" \
| Rscript -e 'pak::pkg_install(strsplit(readLines("stdin"), ", ?")[[1L]], ask = FALSE)' \
&& Rscript -e 'pak::cache_clean()'
我怀疑这与 Jenkins 有关,因为构建从命令行运行良好。 Jenkins 中是否有某些设置会减慢这些软件包的下载和安装速度?谢谢。
想通了,需要用前面的 \ 转义 $ 字符,这样它就不会被计算。基本上将 "$PKGS"
替换为 "\$PKGS"
.