File size: 2,950 Bytes
e0c44d0
 
13a11e3
 
846ccf2
e0c44d0
 
 
 
 
 
 
 
 
13a11e3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e0c44d0
 
13a11e3
 
 
 
 
 
 
 
 
 
 
 
 
 
e0c44d0
13a11e3
 
 
e0c44d0
13a11e3
 
e0c44d0
13a11e3
e0c44d0
 
 
 
 
 
 
 
 
 
13a11e3
e0c44d0
13a11e3
 
 
 
e0c44d0
13a11e3
e0c44d0
13a11e3
 
e0c44d0
 
 
 
 
 
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
FROM rocker/shiny-verse:latest

ENV LANG=C.UTF-8 \
    LC_ALL=C.UTF-8

RUN useradd -m -u 1000 user

ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH

RUN mkdir -p $HOME/app && chown user:user $HOME/app

WORKDIR $HOME/app

# System dependencies (use fast Azure mirror and skip recommended packages to avoid timeouts)
RUN if [ -f /etc/apt/sources.list.d/ubuntu.sources ]; then \
        sed -i 's/archive\.ubuntu\.com/azure.archive.ubuntu.com/g; s/security\.ubuntu\.com/azure.archive.ubuntu.com/g' /etc/apt/sources.list.d/ubuntu.sources; \
    fi && \
    if [ -f /etc/apt/sources.list ]; then \
        sed -i 's/archive\.ubuntu\.com/azure.archive.ubuntu.com/g; s/security\.ubuntu\.com/azure.archive.ubuntu.com/g' /etc/apt/sources.list; \
    fi && \
    apt-get update && apt-get install -y --no-install-recommends \
        libssl-dev \
        libcurl4-openssl-dev \
        libudunits2-dev \
        libgdal-dev \
        gdal-bin \
        libgeos-dev \
        libproj-dev \
        libsqlite3-dev \
        libabsl-dev \
        tzdata \
    && rm -rf /var/lib/apt/lists/*

# Ensure Posit Package Manager (PPM) binary repo matches the container's Ubuntu codename
# (prevents GDAL/system ABI mismatches when rocker/shiny-verse:latest advances Ubuntu releases)
RUN . /etc/os-release && \
    PPM_REPO="${CRAN:-https://p3m.dev/cran/__linux__/${UBUNTU_CODENAME}/latest}" && \
    mkdir -p /usr/local/lib/R/etc /etc/R && \
    { \
        echo "options(repos = c(CRAN = '${PPM_REPO}'), download.file.method = 'libcurl')"; \
        echo 'options(HTTPUserAgent = sprintf("R/%s R (%s)", getRversion(), paste(getRversion(), R.version$platform, R.version$arch, R.version$os)))'; \
        echo 'options(Ncpus = max(1L, parallel::detectCores()))'; \
    } > /usr/local/lib/R/etc/Rprofile.site && \
    cp /usr/local/lib/R/etc/Rprofile.site /etc/R/Rprofile.site

# Install R packages from the OS-matched PPM repository configured above
RUN install2.r --error --skipinstalled \
    shiny \
    bslib \
    httpuv \
    bsicons \
    leaflet \
    mapgl \
    sf \
    dplyr \
    tidyr \
    readr \
    DT \
    scales \
    plotly \
    lubridate \
    shinycssloaders \
    later \
    RColorBrewer \
    curl \
    shinyjs \
    jsonlite \
    writexl \
    htmltools

# Fail fast at build time if any core package or system shared library fails to load
RUN Rscript -e 'pkgs <- c("shiny", "bslib", "httpuv", "bsicons", "leaflet", "mapgl", "sf", "dplyr", "tidyr", "readr", "DT", "scales", "plotly", "lubridate", "shinycssloaders", "later", "RColorBrewer", "curl", "shinyjs", "jsonlite", "writexl", "htmltools"); invisible(lapply(pkgs, library, character.only = TRUE)); cat("Verified core R packages and shared libraries.\n")'

COPY --chown=user:user . $HOME/app

RUN mkdir -p $HOME/app/data && \
    chown -R user:user $HOME/app

USER user

EXPOSE 7860

CMD ["R", "--quiet", "-e", "shiny::runApp('/home/user/app', host='0.0.0.0', port=7860)"]