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 }}"
13 changes: 9 additions & 4 deletions minimal-slim/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@
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
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
# Omitting: gdal-bin, netcdf-bin, postgis, Jupyter, pandoc, TeX, Java
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
libopenblas0-pthread \
libgdal-dev \
libgeos-dev \
libproj-dev \
Expand All @@ -15,13 +21,12 @@ RUN apt-get update \

# 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 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 \
&& find /usr/local/lib/R/site-library/*/libs -name '*.so' -exec strip --strip-unneeded {} + 2>/dev/null || true \
&& 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

# Default command
CMD ["R"]
15 changes: 9 additions & 6 deletions minimal/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ 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 \
Expand All @@ -14,15 +19,15 @@ RUN apt-get update \
# - 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)"
# 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-debug /usr/local/lib/R/site-library/*/libs/*.so 2>/dev/null || true \
&& rm -rf /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 +40,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/*
12 changes: 5 additions & 7 deletions osgeo/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
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 R -e "if (!requireNamespace('pak', quietly = TRUE)) install.packages('pak', repos = 'https://cloud.r-project.org/'); pak::pak('geocompx/geocompkg', upgrade = TRUE)" \
&& strip --strip-debug /usr/local/lib/R/site-library/*/libs/*.so 2>/dev/null || true \
&& rm -rf /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
17 changes: 9 additions & 8 deletions python/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@ 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
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"

# Install dependencies, git, and gh cli (no build-essential needed since uv installs binary wheels)
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
build-essential \
curl \
git \
unzip \
Expand All @@ -20,7 +24,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
&& 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 \
&& apt-get install -y --no-install-recommends gh \
&& rm -rf /var/lib/apt/lists/*

# Install quarto
Expand All @@ -39,6 +43,3 @@ RUN wget -q -O /tmp/requirements.txt https://raw.githubusercontent.com/geocompx/
&& 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/*
55 changes: 38 additions & 17 deletions pythonr/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ 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)
# along with multi-threaded OpenBLAS and required C/C++ runtime/header libraries using --no-install-recommends
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 \
Expand All @@ -27,14 +27,35 @@ RUN . /etc/os-release && \
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 \
&& 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 \
&& ln -sfn /opt/quarto/bin/tools/pandoc /usr/local/bin/pandoc \
&& rm -rf /tmp/r.deb /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
Expand All @@ -55,12 +76,12 @@ 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)" && \
# Install pak + geocompkg (including Suggests) + VS Code R extension (vscode-R v3+) dependencies
# with pkg.sysreqs = FALSE (all required C/C++ runtime libs are installed above with --no-install-recommends)
# and strip debug symbols from compiled R shared objects in the same layer
RUN 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)" && \
strip --strip-debug /opt/R/current/lib/R/library/*/libs/*.so 2>/dev/null || true && \
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/*
40 changes: 19 additions & 21 deletions rocker-rpy/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,29 @@ 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
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 \
&& rm /tmp/requirements.txt
27 changes: 11 additions & 16 deletions rust/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/*
4 changes: 3 additions & 1 deletion suggests/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ 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 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-debug /usr/local/lib/R/site-library/*/libs/*.so 2>/dev/null || true \
&& rm -rf /tmp/* /root/.cache/R/pkgcache /var/lib/apt/lists/*
Loading