Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
21 changes: 13 additions & 8 deletions minimal-slim/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
20 changes: 10 additions & 10 deletions minimal/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,27 @@ LABEL org.opencontainers.image.authors="Robin Lovelace <rob00x@gmail.com>, 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 \
Expand All @@ -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/*
13 changes: 6 additions & 7 deletions osgeo/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
59 changes: 35 additions & 24 deletions python/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/*
70 changes: 43 additions & 27 deletions pythonr/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,51 @@ LABEL org.opencontainers.image.authors="Robin Lovelace <rob00x@gmail.com>" \
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 2 (Ultra-Slim Runtime): Posit R (which includes gcc/g++/gfortran/make/openblas-dev) + exact runtime .so libraries
# without 650 MB of libboost1.83-dev / libllvm19 / libspatialite-dev / python3.13 / third-party static .a archives
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 \
liblapack-dev \
libomp-dev \
gfortran \
libudunits2-dev \
libgdal-dev \
libgeos-dev \
libproj-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 \
liblapack3 \
libgdal36 \
libgeos-c1t64 \
libproj25 \
libudunits2-0 \
libglpk40 \
libmagick++-7.q16-5 \
libnode115 \
libgit2-1.9 \
libabsl20240722 \
libuv1t64 \
libfribidi0 \
libharfbuzz0b \
libtiffxx6 \
&& 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 <<EOF > /opt/R/current/lib/R/etc/Rprofile.site
Expand All @@ -55,12 +66,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/*
45 changes: 21 additions & 24 deletions rocker-rpy/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading
Loading