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)"]