Spaces:
Build error
Build error
Create Dockerfile
Browse files- Dockerfile +32 -0
Dockerfile
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 使用一个包含 R 的基础镜像
|
| 2 |
+
# 你可以使用 rocker/r-base 或 rocker/tidyverse 等预构建的 R 镜像
|
| 3 |
+
FROM rocker/tidyverse:latest
|
| 4 |
+
|
| 5 |
+
# 设置工作目录
|
| 6 |
+
WORKDIR /app
|
| 7 |
+
|
| 8 |
+
# 复制你的 R 脚本和数据文件到容器中
|
| 9 |
+
COPY app.R .
|
| 10 |
+
COPY gmqrkl.xlsx .
|
| 11 |
+
|
| 12 |
+
# 安装所有必需的 R 包
|
| 13 |
+
# 在 RUN 命令中一次性安装所有包,可以减少 Docker 镜像层数
|
| 14 |
+
# 使用 apt-get 安装系统级别的依赖(例如 r-cran-rjava 如果你需要)
|
| 15 |
+
# 这里我们只安装 R 包
|
| 16 |
+
RUN R -e "install.packages(c('zoo', 'forecast', 'tseries', 'ggplot2', 'uroot', 'readxl', 'dplyr', 'lubridate', 'prophet', 'ggpubr', 'patchwork', 'scales', 'parallel', 'doParallel', 'Rcpp', 'RcppArmadillo', 'RcppParallel'), repos='http://cran.rstudio.com/')"
|
| 17 |
+
|
| 18 |
+
# 针对 prophet 包的额外依赖(如果遇到问题,可能需要手动安装这些)
|
| 19 |
+
# RUN R -e "install.packages('Rcpp', repos='http://cran.rstudio.com/')"
|
| 20 |
+
# RUN R -e "install.packages('RcppArmadillo', repos='http://cran.rstudio.com/')"
|
| 21 |
+
# RUN R -e "install.packages('RcppParallel', repos='http://cran.rstudio.com/')"
|
| 22 |
+
|
| 23 |
+
# 如果你的代码需要特殊字体来显示中文,可以安装字体
|
| 24 |
+
# RUN apt-get update && apt-get install -y fonts-wqy-zenhei
|
| 25 |
+
|
| 26 |
+
# 设置环境变量,确保 R 知道去哪里找字体(如果安装了)
|
| 27 |
+
# ENV R_LIBS_USER=/usr/local/lib/R/site-library
|
| 28 |
+
# ENV R_GSCMD=/usr/bin/gs # For ghostscript, sometimes needed for ggplot2 output
|
| 29 |
+
|
| 30 |
+
# 运行你的 R 脚本
|
| 31 |
+
# 如果你的 R 脚本会生成文件(如图片),请确保它们保存在 /app 目录下
|
| 32 |
+
CMD ["Rscript", "app.R"]
|