diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index 4a0fbb3..0660f8e 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -52,5 +52,7 @@ jobs: push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha,scope=${{ inputs.image }} + cache-to: type=gha,mode=max,scope=${{ inputs.image }} secrets: | "GITHUB_PAT=${{ secrets.GITHUB_TOKEN }}" diff --git a/minimal-slim/Dockerfile b/minimal-slim/Dockerfile index 8c73223..e5dcb5e 100644 --- a/minimal-slim/Dockerfile +++ b/minimal-slim/Dockerfile @@ -2,26 +2,31 @@ ARG R_VER=4.6.2 FROM rocker/r-ver:${R_VER} -# System dependencies: keep only what sf/terra/spData need at runtime/build time -# Omitting: gdal-bin, netcdf-bin, postgis, Jupyter, pandoc, TeX, Java +ENV GDAL_NUM_THREADS="ALL_CPUS" \ + GDAL_CACHEMAX="512" \ + VSI_CACHE="TRUE" \ + GDAL_HTTP_MULTIPLEX="YES" + +# System dependencies: keep only what sf/terra/spData need at runtime/build time + multi-threaded OpenBLAS +# Remove unused third-party static .a archives in the same layer RUN apt-get update \ && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + libopenblas0-pthread \ libgdal-dev \ libgeos-dev \ libproj-dev \ libudunits2-dev \ libssl-dev \ - && rm -rf /var/lib/apt/lists/* + && find /usr/lib/*-linux-gnu -name "*.a" ! -name "*nonshared*" ! -name "libc.a" ! -name "libm.a" -delete \ + && rm -rf /usr/share/doc/* /usr/share/man/* /var/lib/apt/lists/* # R packages: geocompx/geocompkg Imports + VS Code R extension (vscode-R v3+) dependencies -# Using install2.r from rocker-versioned2 style (lightweight, no extra system deps) +# Strip binary .so files and static vignettes in the same layer to reduce image size ARG NCPUS=-1 RUN install2.r --error --skipmissing --skipinstalled -n "${NCPUS}" \ sf terra spData units dplyr methods languageserver httpgd jgd rstudioapi processx ps later jsonlite svglite \ - && rm -rf /tmp/downloaded_packages - -# Strip binary .so files from RSPM installs -RUN find /usr/local/lib/R/site-library/*/libs -name '*.so' -exec strip --strip-unneeded {} + 2>/dev/null || true + && (find /usr/local/lib/R/site-library/*/libs -name '*.so' -exec strip --strip-unneeded {} + 2>/dev/null || true) \ + && rm -rf /usr/local/lib/R/site-library/*/doc /tmp/downloaded_packages # Default command CMD ["R"] diff --git a/minimal/Dockerfile b/minimal/Dockerfile index a9c2c03..92d317e 100644 --- a/minimal/Dockerfile +++ b/minimal/Dockerfile @@ -4,25 +4,27 @@ LABEL org.opencontainers.image.authors="Robin Lovelace , Jakub org.opencontainers.image.source="https://github.com/geocompx/docker" \ devcontainer.metadata='[{"customizations":{"vscode":{"extensions":["REditorSupport.r","Posit.air-vscode","quarto.quarto"],"settings":{"r.rterm.linux":"/usr/local/bin/R","r.rpath.linux":"/usr/local/bin/R","r.lsp.path":"/usr/local/bin/R","r.plot.backend":"auto","r.sessionWatcher":true,"r.bracketedPaste":true,"r.interactive.executionTarget":"terminal"}}}}]' +ENV GDAL_NUM_THREADS="ALL_CPUS" \ + GDAL_CACHEMAX="512" \ + VSI_CACHE="TRUE" \ + GDAL_HTTP_MULTIPLEX="YES" + RUN apt-get update \ && DEBIAN_FRONTEND=noninteractive apt-get purge -y postgis netcdf-bin \ && apt-get autoremove -y \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* -# Install essential geocompkg Imports + VS Code R extension (vscode-R v3+) session/plot/LSP dependencies: -# - languageserver: R LSP support -# - httpgd, jgd, rstudioapi, svglite: plot backends & rstudioapi emulation in vscode-R v3+ -# - processx, ps, later, jsonlite: required by vscode-R's bundled `sess` package so first-run installation is instantaneous -RUN R -e "if (!requireNamespace('pak', quietly = TRUE)) install.packages('pak', repos = 'https://cloud.r-project.org/'); pak::pak(c('sf','terra','spData','units','dplyr','languageserver','httpgd','jgd','rstudioapi','processx','ps','later','jsonlite','svglite','methods'), upgrade = FALSE)" +# Install essential geocompkg Imports + VS Code R extension (vscode-R v3+) session/plot/LSP dependencies +# Strip debug symbols from compiled R package shared objects and clean pkgcache in the same layer +RUN R -e "if (!requireNamespace('pak', quietly = TRUE)) install.packages('pak', repos = 'https://cloud.r-project.org/'); pak::pak(c('sf','terra','spData','units','dplyr','languageserver','httpgd','jgd','rstudioapi','processx','ps','later','jsonlite','svglite','methods'), upgrade = FALSE)" \ + && (strip --strip-unneeded /usr/local/lib/R/site-library/*/libs/*.so 2>/dev/null || true) \ + && rm -rf /usr/local/lib/R/site-library/*/doc /tmp/* /root/.cache/R/pkgcache /var/lib/apt/lists/* # Install arf (modern Rust-based R console used by vscode-R persistent interactive sessions) RUN wget -qO- https://github.com/eitsupi/arf/releases/latest/download/arf-console-installer.sh | env CARGO_DIST_FORCE_INSTALL_DIR=/usr/local sh \ && /usr/local/bin/arf --version -# Strip debug symbols from compiled R package shared objects to save ~200MB -RUN strip /usr/local/lib/R/site-library/*/libs/*.so - # Disable inline RMarkdown/Quarto chunk output in RStudio RUN echo '{' > /etc/rstudio/rstudio-prefs.json \ && echo ' "rmd_chunk_output_inline": false' >> /etc/rstudio/rstudio-prefs.json \ @@ -35,5 +37,3 @@ RUN echo 'if (interactive() && (Sys.getenv("TERM_PROGRAM") == "vscode" || Sys.ge && echo ' options(device = httpgd::hgd)' >> /usr/local/lib/R/etc/Rprofile.site \ && echo ' }' >> /usr/local/lib/R/etc/Rprofile.site \ && echo '}' >> /usr/local/lib/R/etc/Rprofile.site - -RUN rm -rf /var/lib/apt/lists/* diff --git a/osgeo/Dockerfile b/osgeo/Dockerfile index 8f3a7f5..7d240ff 100644 --- a/osgeo/Dockerfile +++ b/osgeo/Dockerfile @@ -1,9 +1,8 @@ FROM rocker/geospatial:dev-osgeo -RUN R -e "if (!requireNamespace('pak', quietly = TRUE)) install.packages('pak', repos = 'https://cloud.r-project.org/'); pak::pak('geocompx/geocompkg', upgrade = TRUE)" - -# Set RStudio preferences -# No inline code: -RUN echo '{' >> /etc/rstudio/rstudio-prefs.json -RUN echo ' "rmd_chunk_output_inline": false' >> /etc/rstudio/rstudio-prefs.json -RUN echo '}' >> /etc/rstudio/rstudio-prefs.json +RUN export MAKEFLAGS="-j$(nproc)" \ + && R -e "if (!requireNamespace('pak', quietly = TRUE)) install.packages('pak', repos = 'https://cloud.r-project.org/'); pak::pak('geocompx/geocompkg', upgrade = TRUE)" \ + && (strip --strip-unneeded /usr/local/lib/R/site-library/*/libs/*.so 2>/dev/null || true) \ + && rm -rf /usr/local/lib/R/site-library/*/doc /tmp/* /root/.cache/R/pkgcache /var/lib/apt/lists/* +# Set RStudio preferences (no inline code) +RUN printf '{\n "rmd_chunk_output_inline": false\n}\n' > /etc/rstudio/rstudio-prefs.json diff --git a/python/Dockerfile b/python/Dockerfile index b2bf169..7b52d26 100644 --- a/python/Dockerfile +++ b/python/Dockerfile @@ -6,39 +6,50 @@ ARG QUARTO_VERSION=1.11.9 LABEL devcontainer.metadata='[{"customizations":{"vscode":{"extensions":["quarto.quarto","ms-python.python","ms-toolsai.jupyter"],"settings":{"python.defaultInterpreterPath":"/usr/local/bin/python"}}}}]' ENV QUARTO_PYTHON="/usr/local/bin/python" \ - RETICULATE_PYTHON="/usr/local/bin/python" - -# Install dependencies, git, and gh cli -RUN apt-get update && apt-get install -y --no-install-recommends \ - ca-certificates \ - build-essential \ - curl \ - git \ - unzip \ - wget \ + RETICULATE_PYTHON="/usr/local/bin/python" \ + GDAL_NUM_THREADS="ALL_CPUS" \ + GDAL_CACHEMAX="512" \ + VSI_CACHE="TRUE" \ + GDAL_HTTP_MULTIPLEX="YES" \ + PYOGRIO_USE_ARROW="1" + +# Configure dpkg to exclude documentation, manpages, and locale translations across all layers, +# and install dependencies, git, gh cli, and quarto in a single clean layer with SHA-256 inode deduplication +RUN printf "path-exclude /usr/share/doc/*\npath-exclude /usr/share/man/*\npath-exclude /usr/share/locale/*\npath-exclude /usr/share/info/*\n" > /etc/dpkg/dpkg.cfg.d/docker-no-doc \ + && apt-get update && apt-get install -y --no-install-recommends \ + ca-certificates \ + curl \ + git \ + unzip \ + wget \ && curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \ && chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \ && echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" > /etc/apt/sources.list.d/github-cli.list \ - && apt-get update \ - && apt-get install -y gh \ - && rm -rf /var/lib/apt/lists/* - -# Install quarto -RUN arch="$(dpkg --print-architecture)" \ + && arch="$(dpkg --print-architecture)" \ && wget -q "https://github.com/quarto-dev/quarto-cli/releases/download/v${QUARTO_VERSION}/quarto-${QUARTO_VERSION}-linux-${arch}.deb" \ && apt-get update \ - && apt-get install -y --no-install-recommends "./quarto-${QUARTO_VERSION}-linux-${arch}.deb" \ + && apt-get install -y --no-install-recommends gh "./quarto-${QUARTO_VERSION}-linux-${arch}.deb" \ && rm "quarto-${QUARTO_VERSION}-linux-${arch}.deb" \ - && rm -rf /var/lib/apt/lists/* + && python -c 'import os,hashlib; seen={}; [([os.unlink(p),os.link(seen[h],p)] if h in seen else seen.setdefault(h,p)) for r,_,fs in os.walk("/opt/quarto") for f in fs if not os.path.islink(p:=os.path.join(r,f)) and (s:=os.path.getsize(p))>4096 and (h:=(s,hashlib.sha256(open(p,"rb").read()).hexdigest()))]' \ + && rm -rf /usr/share/doc/* /usr/share/man/* /usr/share/locale/* /var/lib/apt/lists/* # Install uv for fast Python package & project management COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /usr/local/bin/ -# Install requirements using uv for fast parallel wheel resolution -RUN wget -q -O /tmp/requirements.txt https://raw.githubusercontent.com/geocompx/geocompy/main/requirements.txt \ +# Install requirements using uv, strip debug symbols from compiled C/C++ shared libraries, +# prune bundled package unit test suites/C++ headers, and hardlink duplicate files in site-packages +RUN apt-get update && apt-get install -y --no-install-recommends binutils \ + && wget -q -O /tmp/requirements.txt https://raw.githubusercontent.com/geocompx/geocompy/main/requirements.txt \ && sed -i 's/==/>=/g' /tmp/requirements.txt \ && uv pip install --system --no-cache -r /tmp/requirements.txt seaborn openpyxl statsmodels pyarrow \ - && rm /tmp/requirements.txt - -# Clean up build tools to reduce image size (optional but recommended) -RUN apt purge -y build-essential && apt autoremove -y && rm -rf /var/lib/apt/lists/* + && (find /usr/local/lib/python3.14/site-packages -name "*.so*" -type f -exec strip --strip-unneeded {} + 2>/dev/null || true) \ + && (find /usr/local/lib/python3.14/site-packages -type d -name "tests" -prune -exec rm -rf {} + 2>/dev/null || true) \ + && rm -rf /usr/local/lib/python3.14/site-packages/pyarrow/include \ + /usr/local/lib/python3.14/site-packages/numpy/_core/include \ + /usr/local/lib/python3.14/site-packages/numpy/f2py/src \ + /usr/local/lib/python3.14/site-packages/jupyterlab/galata \ + /usr/local/lib/python3.14/site-packages/jedi/third_party/django-stubs \ + && (find /usr/local/lib/python3.14/site-packages -name "*.js.map" -delete 2>/dev/null || true) \ + && python -c 'import os,hashlib; seen={}; [([os.unlink(p),os.link(seen[h],p)] if h in seen else seen.setdefault(h,p)) for r,_,fs in os.walk("/usr/local/lib/python3.14/site-packages") for f in fs if not os.path.islink(p:=os.path.join(r,f)) and (s:=os.path.getsize(p))>4096 and (h:=(s,hashlib.sha256(open(p,"rb").read()).hexdigest()))]' \ + && apt-get purge -y --auto-remove binutils \ + && rm -rf /tmp/requirements.txt /var/lib/apt/lists/* diff --git a/pythonr/Dockerfile b/pythonr/Dockerfile index 08a8671..296c1a8 100644 --- a/pythonr/Dockerfile +++ b/pythonr/Dockerfile @@ -4,40 +4,60 @@ LABEL org.opencontainers.image.authors="Robin Lovelace " \ org.opencontainers.image.source="https://github.com/geocompx/docker" \ devcontainer.metadata='[{"customizations":{"vscode":{"extensions":["REditorSupport.r","Posit.air-vscode","quarto.quarto","ms-python.python"],"settings":{"r.rterm.linux":"/usr/local/bin/R","r.rpath.linux":"/usr/local/bin/R","r.lsp.path":"/usr/local/bin/R","r.plot.backend":"auto","r.sessionWatcher":true,"r.bracketedPaste":true,"r.interactive.executionTarget":"terminal"}}}}]' -RUN apt-get update && apt-get install -y --no-install-recommends \ - curl \ - libdeflate0 \ - locales \ - xz-utils \ - && rm -rf /var/lib/apt/lists/* - -# Install R from Posit's precompiled Debian repository (auto-detecting Debian 12 bookworm vs Debian 13 trixie) +# Contender 1 (Dev-Ready Slim): Keep C/C++ -dev headers for source builds, drop Clang libomp-dev (GCC uses libgomp1), +# and remove unused third-party static .a archives in /usr/lib/*-linux-gnu while preserving /usr/lib/gcc and *nonshared.a ARG R_VERSION=4.6.2 RUN . /etc/os-release && \ if [ "${VERSION_ID}" = "12" ]; then R_VER="4.6.0"; else R_VER="${R_VERSION}"; fi && \ - curl -fSL -o /tmp/r.deb "https://cdn.posit.co/r/debian-${VERSION_ID}/pkgs/r-${R_VER}_1_$(dpkg --print-architecture).deb" && \ apt-get update && \ - apt-get install -y /tmp/r.deb \ - libblas-dev \ + apt-get install -y --no-install-recommends \ + curl \ + libdeflate0 \ + locales \ + xz-utils && \ + curl -fSL -o /tmp/r.deb "https://cdn.posit.co/r/debian-${VERSION_ID}/pkgs/r-${R_VER}_1_$(dpkg --print-architecture).deb" && \ + apt-get install -y --no-install-recommends /tmp/r.deb \ + libopenblas0-pthread \ + libopenblas-dev \ liblapack-dev \ - libomp-dev \ gfortran \ libudunits2-dev \ libgdal-dev \ libgeos-dev \ libproj-dev \ libglpk40 \ + libglpk-dev \ + libcurl4-openssl-dev \ + libssl-dev \ + libxml2-dev \ + libfontconfig1-dev \ + libfreetype6-dev \ + libfribidi-dev \ + libharfbuzz-dev \ + libgit2-dev \ + libmagick++-dev \ + libnode-dev \ + libcairo2-dev \ + libx11-dev \ + libuv1-dev \ + libabsl-dev \ + && find /usr/lib/*-linux-gnu -name "*.a" ! -name "*nonshared*" ! -name "libc.a" ! -name "libm.a" -delete \ && ln -sfn "/opt/R/${R_VER}" /opt/R/current \ && ln -sfn /opt/R/current/bin/R /usr/local/bin/R \ && ln -sfn /opt/R/current/bin/Rscript /usr/local/bin/Rscript \ - && rm -rf /tmp/r.deb /var/lib/apt/lists/* + && ln -sfn /opt/quarto/bin/tools/pandoc /usr/local/bin/pandoc \ + && rm -rf /tmp/r.deb /usr/share/doc/* /usr/share/man/* /var/lib/apt/lists/* ENV PATH="/opt/R/current/bin:/usr/local/bin:${PATH}" \ QUARTO_PYTHON="/usr/local/bin/python" \ - RETICULATE_PYTHON="/usr/local/bin/python" + RETICULATE_PYTHON="/usr/local/bin/python" \ + GDAL_NUM_THREADS="ALL_CPUS" \ + GDAL_CACHEMAX="512" \ + VSI_CACHE="TRUE" \ + GDAL_HTTP_MULTIPLEX="YES" \ + PYOGRIO_USE_ARROW="1" # Configure Rprofile.site and /root/.Rprofile with P3M binary repository and HTTPUserAgent -# so both pak and base install.packages() receive precompiled Linux binary packages from P3M RUN . /etc/os-release && \ mkdir -p /etc/R /opt/R/current/lib/R/etc /root && \ cat < /opt/R/current/lib/R/etc/Rprofile.site @@ -55,12 +75,17 @@ RUN cp /opt/R/current/lib/R/etc/Rprofile.site /etc/R/Rprofile.site && \ RUN curl --proto '=https' --tlsv1.2 -LsSf https://github.com/eitsupi/arf/releases/latest/download/arf-console-installer.sh | env CARGO_DIST_FORCE_INSTALL_DIR=/usr/local sh \ && /usr/local/bin/arf --version -# Install pak from precompiled binary -RUN R -e "install.packages('pak')" - -# Install geocompkg (including Suggests) + VS Code R extension (vscode-R v3+) dependencies -# using pak so system requirements and precompiled P3M/r-universe binaries are resolved in parallel -RUN Rscript -e "options(repos = c(geocompx = 'https://geocompx.r-universe.dev', mlrorg = 'https://mlr-org.r-universe.dev', getOption('repos'))); pak::pak(c('sf', 'geocompkg', 'languageserver', 'httpgd', 'jgd', 'rstudioapi', 'processx', 'ps', 'later', 'jsonlite', 'svglite', 'reticulate'), dependencies = TRUE)" && \ +# Parallel source build via MAKEFLAGS, strip .so debug symbols, prune static vignettes & googlePolylines Boost header cache, +# hardlink duplicate files, and assert zero missing shared libraries across all installed R .so objects +RUN export MAKEFLAGS="-j$(nproc)" && \ + R -e "install.packages('pak')" && \ + Rscript -e "options(pkg.sysreqs = FALSE, repos = c(geocompx = 'https://geocompx.r-universe.dev', mlrorg = 'https://mlr-org.r-universe.dev', getOption('repos'))); pak::pak(c('sf', 'geocompkg', 'languageserver', 'httpgd', 'jgd', 'rstudioapi', 'processx', 'ps', 'later', 'jsonlite', 'svglite', 'reticulate'), dependencies = TRUE)" && \ + ! (LD_LIBRARY_PATH="/opt/R/current/lib/R/lib:${LD_LIBRARY_PATH}" ldd /opt/R/current/lib/R/library/*/libs/*.so 2>/dev/null | grep "not found") && \ + (strip --strip-unneeded /opt/R/current/lib/R/library/*/libs/*.so 2>/dev/null || true) && \ + rm -rf /opt/R/current/lib/R/library/*/doc \ + /opt/R/current/lib/R/library/googlePolylines/i \ + /opt/R/current/lib/R/doc && \ + python -c 'import os,hashlib; seen={}; [([os.unlink(p),os.link(seen[h],p)] if h in seen else seen.setdefault(h,p)) for r,_,fs in os.walk("/opt/R/current/lib/R/library") for f in fs if not os.path.islink(p:=os.path.join(r,f)) and (s:=os.path.getsize(p))>4096 and (h:=(s,hashlib.sha256(open(p,"rb").read()).hexdigest()))]' && \ ln -sf /usr/local/bin/python /usr/bin/python3 && \ ln -sf /usr/local/bin/python /usr/bin/python && \ rm -rf /tmp/* /root/.cache/R/pkgcache /var/lib/apt/lists/* diff --git a/rocker-rpy/Dockerfile b/rocker-rpy/Dockerfile index 60765c3..72291bd 100644 --- a/rocker-rpy/Dockerfile +++ b/rocker-rpy/Dockerfile @@ -2,38 +2,35 @@ FROM ghcr.io/geocompx/minimal # Install core Python 3 packages and other dependencies. -# - python3-dev: Headers needed to compile certain Python packages with C extensions. -# - python3-pip: The package installer for Python 3, installed globally. -# - swig: Used for wrapping C/C++ libraries for Python. RUN apt-get update && apt-get install -y --no-install-recommends \ python3 \ python3-dev \ python3-pip \ - swig && \ - rm -rf /var/lib/apt/lists/* - -# Create a symbolic link so the 'python' command defaults to 'python3' -# The '-f' flag forces the creation of the symbolic link, overwriting any existing file. -RUN ln -sf /usr/bin/python3 /usr/bin/python - -# Create a symbolic link so the 'pip' command defaults to 'pip3' -# The '-f' flag forces the creation of the symbolic link, overwriting any existing file. -RUN ln -sf /usr/bin/pip3 /usr/bin/pip + swig \ + && ln -sf /usr/bin/python3 /usr/bin/python \ + && ln -sf /usr/bin/pip3 /usr/bin/pip \ + && rm -rf /var/lib/apt/lists/* # Install reticulate R package to enable R-Python interoperability -# This step remains the same as it is a separate R installation. -RUN R -e "install.packages('reticulate', repos='https://cloud.r-project.org/')" +RUN R -e "install.packages('reticulate', repos='https://cloud.r-project.org/')" \ + && rm -rf /tmp/* + +# Set the environment variables for Quarto, Reticulate, GDAL, and Pyogrio +ENV QUARTO_PYTHON=/usr/bin/python \ + RETICULATE_PYTHON=/usr/bin/python \ + GDAL_NUM_THREADS="ALL_CPUS" \ + GDAL_CACHEMAX="512" \ + VSI_CACHE="TRUE" \ + GDAL_HTTP_MULTIPLEX="YES" \ + PYOGRIO_USE_ARROW="1" -# Set the environment variable for Quarto to use the system Python 3. -# The `which python3` command finds the path of the globally installed executable. -ENV QUARTO_PYTHON=/usr/bin/python +# Install uv for fast parallel Python wheel resolution +COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /usr/local/bin/ -# Install project requirements globally using the system's pip3. -# We use `pip3` to ensure we are using the package manager for Python 3. -# The `--break-system-packages` flag is added to override the security feature. -# The `--ignore-installed` flag is added to prevent pip from trying to uninstall -# packages that are managed by the system. +# Install project requirements globally using uv, strip debug symbols, and prune test directories RUN wget -q -O /tmp/requirements.txt https://github.com/geocompx/geocompy/raw/refs/heads/main/requirements.txt \ && sed -i 's/==/>=/g' /tmp/requirements.txt \ - && pip3 install --no-cache-dir --break-system-packages --ignore-installed -r /tmp/requirements.txt \ + && uv pip install --system --break-system-packages --reinstall-package pyyaml --no-cache -r /tmp/requirements.txt \ + && (find /usr/local/lib/python*/dist-packages -name "*.so*" -type f -exec strip --strip-unneeded {} + 2>/dev/null || true) \ + && (find /usr/local/lib/python*/dist-packages -type d -name "tests" -prune -exec rm -rf {} + 2>/dev/null || true) \ && rm /tmp/requirements.txt diff --git a/rust/Dockerfile b/rust/Dockerfile index 0e25c41..42a32db 100644 --- a/rust/Dockerfile +++ b/rust/Dockerfile @@ -3,29 +3,24 @@ FROM ghcr.io/geocompx/suggests # od2net R package: https://urban-analytics-technology-platform.github.io/od2net/r/ RUN git clone --depth 1 https://github.com/a-b-street/od2net.git /tmp/od2net \ && R -e "if (!requireNamespace('pak', quietly = TRUE)) install.packages('pak', repos = 'https://cloud.r-project.org/'); pak::local_install('/tmp/od2net/r', upgrade = TRUE, dependencies = TRUE)" \ - && rm -rf /tmp/od2net + && rm -rf /tmp/od2net /root/.cache/R/pkgcache + # robinlovelace/simodels: -RUN R -e "if (!requireNamespace('pak', quietly = TRUE)) install.packages('pak', repos = 'https://cloud.r-project.org/'); pak::pak('robinlovelace/simodels', upgrade = TRUE, dependencies = TRUE)" +RUN R -e "if (!requireNamespace('pak', quietly = TRUE)) install.packages('pak', repos = 'https://cloud.r-project.org/'); pak::pak('robinlovelace/simodels', upgrade = TRUE, dependencies = TRUE)" \ + && rm -rf /tmp/* /root/.cache/R/pkgcache RUN apt-get update && apt-get install -y --no-install-recommends \ curl \ - && rm -rf /var/lib/apt/lists/* \ - && curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain stable -y \ + osmium-tool \ + && curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain stable --profile minimal -y \ && export PATH="$HOME/.cargo/bin:$PATH" \ && echo 'export PATH="$HOME/.cargo/bin:$PATH"' >> ~/.profile \ - # Also make cargo available and rustc available with ln -s: && ln -s /root/.cargo/bin/cargo /usr/local/bin/cargo \ && ln -s /root/.cargo/bin/rustc /usr/local/bin/rustc \ && cargo install --locked --git https://github.com/Urban-Analytics-Technology-Platform/od2net \ - && cd /tmp \ - && git clone https://github.com/felt/tippecanoe.git \ - && cd tippecanoe \ - && make -j \ - && make install \ + && ln -s /root/.cargo/bin/od2net /usr/local/bin/od2net \ + && git clone --depth 1 https://github.com/felt/tippecanoe.git /tmp/tippecanoe \ + && make -C /tmp/tippecanoe -j"$(nproc)" \ + && make -C /tmp/tippecanoe install \ && tippecanoe --version \ - && echo "deb http://archive.ubuntu.com/ubuntu/ jammy main restricted" >> /etc/apt/sources.list \ - && apt-get update \ - && apt-get install -y osmium-tool - -# Ensure od2net is available in the PATH: -RUN ln -s /root/.cargo/bin/od2net /usr/local/bin/od2net + && rm -rf /tmp/tippecanoe /root/.cargo/registry /root/.cargo/git /var/lib/apt/lists/* diff --git a/suggests/Dockerfile b/suggests/Dockerfile index a1fe83c..526f3b2 100644 --- a/suggests/Dockerfile +++ b/suggests/Dockerfile @@ -3,4 +3,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ libglpk40 \ nodejs \ && rm -rf /var/lib/apt/lists/* -RUN R -e "options(repos = c(geocompx = 'https://geocompx.r-universe.dev', mlrorg = 'https://mlr-org.r-universe.dev', getOption('repos'))); pak::pak('geocompkg', dependencies = TRUE, upgrade = TRUE)" +RUN export MAKEFLAGS="-j$(nproc)" \ + && R -e "options(repos = c(geocompx = 'https://geocompx.r-universe.dev', mlrorg = 'https://mlr-org.r-universe.dev', getOption('repos'))); pak::pak('geocompkg', dependencies = TRUE, upgrade = TRUE)" \ + && (strip --strip-unneeded /usr/local/lib/R/site-library/*/libs/*.so 2>/dev/null || true) \ + && rm -rf /usr/local/lib/R/site-library/*/doc \ + /usr/local/lib/R/site-library/googlePolylines/i \ + /tmp/* /root/.cache/R/pkgcache /var/lib/apt/lists/*