File size: 2,868 Bytes
028884f
 
648a817
028884f
3fe098e
 
 
028884f
 
 
 
 
3fe098e
028884f
3fe098e
 
 
 
 
 
 
 
028884f
3fe098e
 
028884f
 
 
 
 
3fe098e
028884f
 
 
3fe098e
 
 
028884f
 
 
 
3fe098e
 
 
028884f
 
 
 
 
 
 
3fe098e
 
 
 
028884f
 
 
3fe098e
 
 
de7d245
3fe098e
 
 
028884f
de7d245
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# syntax=docker/dockerfile:1
FROM rocker/r2u:22.04
WORKDIR /code
ARG DEBIAN_FRONTEND=noninteractive
# ==============================================================================
# System dependencies
# ==============================================================================
RUN apt-get update -y && apt-get install -y --no-install-recommends \
    wget bzip2 git unzip ca-certificates locales tzdata \
    build-essential gfortran \
    libcurl4-openssl-dev libssl-dev libxml2-dev libgit2-dev \
    libopenblas-dev liblapack-dev \
    python3 python3-pip \
  && rm -rf /var/lib/apt/lists/*
ENV LC_ALL=C.UTF-8 LANG=C.UTF-8 HF_HUB_DISABLE_TELEMETRY=1
# ==============================================================================
# Python packages
# ==============================================================================
RUN pip3 install --no-cache-dir pandas earthengine-api
# ==============================================================================
# Install R packages (prioritize apt when available for speed)
# ==============================================================================
ARG APT_R_PKGS="\
  r-cran-shiny r-cran-dplyr r-cran-dt \
  r-cran-data.table r-cran-foreach r-cran-doparallel"
RUN set -eux; \
    apt-get update -y; \
    for pkg in $APT_R_PKGS; do \
      if apt-cache show "$pkg" >/dev/null 2>&1; then \
        echo "Installing $pkg via apt ..."; \
        apt-get install -y --no-install-recommends "$pkg" || true; \
      fi; \
    done; \
    rm -rf /var/lib/apt/lists/*
# ==============================================================================
# R packages via CRAN (fallback for those not in apt)
# ==============================================================================
RUN Rscript - <<'RSCRIPT'
options(Ncpus = parallel::detectCores())
cran <- "https://cloud.r-project.org"
req <- c(
  "shiny", "dplyr", "DT", "data.table",
  "bslib", "shinyWidgets", "xgboost",
  "reticulate", "future", "future.apply"
)
installed <- rownames(installed.packages())
need <- setdiff(req, installed)
if (length(need)) {
  if (!requireNamespace("pak", quietly = TRUE)) {
    install.packages("pak", repos = "https://r-lib.github.io/p/pak/stable")
  }
  ok <- tryCatch({
    pak::pak(need)
    TRUE
  }, error = function(e) FALSE)
  if (!ok) install.packages(need, repos = cran)
}
RSCRIPT
# ==============================================================================
# Copy application files
# ==============================================================================
COPY . /code/
# ==============================================================================
# Shiny entrypoint
# ==============================================================================
EXPOSE 7860
CMD ["R", "--quiet", "-e", "port <- as.integer(Sys.getenv('PORT', '7860')); shiny::runApp('/code', host='0.0.0.0', port=port)"]