diff --git a/Dockerfile b/Dockerfile index c3e46da..c296dc1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -32,9 +32,9 @@ RUN CRANLIBS=$(curl https://r-universe.dev/stats/sysdeps/noble | jq --slurp -r ' apt-get clean all # Setup Node, Emscripten & webR -ENV PATH /opt/emsdk:/opt/emsdk/upstream/emscripten:$PATH -ENV EMSDK /opt/emsdk -ENV WEBR_ROOT /opt/webr +ENV PATH=/opt/emsdk:/opt/emsdk/upstream/emscripten:$PATH +ENV EMSDK=/opt/emsdk +ENV WEBR_ROOT=/opt/webr ENV R_LIBS_USER=/opt/R/current/lib/R/site-library @@ -42,9 +42,8 @@ ENV R_LIBS_USER=/opt/R/current/lib/R/site-library COPY Renviron /opt/R/current/lib/R/etc/Renviron.site COPY Rprofile /opt/R/current/lib/R/etc/Rprofile.site -# Install pak and rwasm -RUN R -e 'install.packages("pak")' -RUN R -e 'pak::pak("r-wasm/rwasm")' +# Use devel-pak (until solver hangs are fixed) +RUN R -e 'install.packages("pak", lib = .Library, repos = "https://r-lib.github.io/p/pak/devel/source/linux-gnu/x86_64")' # Set default shell to bash COPY entrypoint.sh /entrypoint.sh diff --git a/Rprofile b/Rprofile index 2a64ed5..adc28cf 100644 --- a/Rprofile +++ b/Rprofile @@ -4,26 +4,20 @@ local({ binary_universe <- function(universe){ sprintf("%s/bin/linux/%s/%s", universe, distro, r_branch) } - bioc_urls <- function(){ - ver <- utils:::.BioC_version_associated_with_R_version(); - c( - BioCsoft = sprintf("https://bioconductor.org/packages/%s/bioc", ver), - BioCann = sprintf("https://bioconductor.org/packages/%s/data/annotation", ver), - BioCexp = sprintf("https://bioconductor.org/packages/%s/data/experiment", ver) - ) - } - options(repos = c( - P3M = sprintf("https://p3m.dev/all/__linux__/%s/latest", distro), - BIOC = binary_universe("https://bioc.r-universe.dev"), - CRAN = "https://cloud.r-project.org", - CRANHAVEN = binary_universe("https://cranhaven.r-universe.dev"), - bioc_urls() - )) - options(HTTPUserAgent = sprintf("R/%s R (%s)", getRversion(), paste(getRversion(), R.version$platform, R.version$arch, R.version$os))) - my_universe <- Sys.getenv("MY_UNIVERSE") - if(nchar(my_universe)){ - options(repos = c(binaries = binary_universe(my_universe), universe = my_universe, getOption("repos"))) + # NB: pak also adds cran and bioconductor automatically when not set already + repos <- c( + BIOC = binary_universe("https://bioc.r-universe.dev"), + PPM = sprintf("https://packagemanager.posit.co/cran/__linux__/%s/latest", distro), + CRAN = 'https://cloud.r-project.org' + ) + if(nchar(Sys.getenv("MY_UNIVERSE"))){ + repos <- c(MY_UNIVERSE = binary_universe(Sys.getenv("MY_UNIVERSE")), repos) } -}) + options( + repos = repos, + HTTPUserAgent = sprintf("R/%s R (%s)", getRversion(), paste(getRversion(), R.version$platform, R.version$arch, R.version$os)) + ) + # print(pak::repo_status()[,1:2]) +}) diff --git a/entrypoint.sh b/entrypoint.sh index 7d959e6..29f47ff 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -17,18 +17,21 @@ export R_LIBS_USER="${PWD}/pkglib" echo "::group::List installed R packages" R -e ".libPaths(); installed.packages()[,1:3]" echo "::endgroup::" + echo "::group::List available wasm libraries" PKG_CONFIG_LIBDIR="${WEBR_ROOT}/wasm/lib/pkgconfig" pkg-config --list-all echo "::endgroup::" + echo "::group::Test that pkg-config works" PKG_CONFIG_LIBDIR="${WEBR_ROOT}/wasm/lib/pkgconfig" pkg-config --libs --cflags gdal echo "::endgroup::" -# For the GitHub Action -if [ "$SOURCEPKG" ]; then - # Workaround for pak resolver hangs - R -e "install.packages(sub('_.*', '', '${SOURCEPKG}'), depends=TRUE)" || true - R -e "rwasm::build('./${SOURCEPKG}')" - BINARYPKG=${SOURCEPKG/.tar.gz/.tgz} - echo "binarypkg=$BINARYPKG" >> $GITHUB_OUTPUT -fi +echo "::group::Install dependencies" +# R -e "install.packages(sub('_.*', '', '${SOURCEPKG}'), depends=TRUE)" || true +R -e "pak::pak(sub('_.*', '', '${SOURCEPKG}'))" +echo "::endgroup::" + +# Compile WASM binary +R -e "rwasm::build('./${SOURCEPKG}')" +BINARYPKG=${SOURCEPKG/.tar.gz/.tgz} +echo "binarypkg=$BINARYPKG" >> $GITHUB_OUTPUT