Skip to content

Feature: Support building containers from CRAN packages with R #873

@FloWuenne

Description

@FloWuenne

Description

Currently, only conda is supported as a python based package management system, which makes it easy to build containers based on python packages. It would be nice to have a similar system in place for R packages on CRAN or bioconductor.

Potential implementation

To achieve a similar implementation via lockfiles as is done with conda and have efficient performance in dependency resolution, one could use pak as the package manager for this implementation.

FROM rocker/r-ubuntu:22.04

# Install pak
RUN Rscript -e " \
    install.packages('pak', repos = sprintf('https://r-lib.github.io/p/pak/stable/%s/%s/%s', .Platform\$pkgType, R.Version()\$os, R.Version()\$arch)); \
    "

## Install desired R packages
RUN Rscript -e "pak::pkg_install(c('plotly', 'shiny', 'DT', 'lubridate', 'here', 'rmarkdown'))"

## Create a lockfile from the installed packages
RUN R -e "user_pkgs <- installed.packages()[is.na(installed.packages()[,'Priority']), ]; pak::lockfile_create(pkg = paste0(user_pkgs[,'Package'], '@', user_pkgs[,'Version']), lockfile = 'environment.lock')"

This approach would use rocker/r-ubuntu as the base image, then install pak using the standard install.packages in R and subsequently use pak to install any desired packages by the user. The last line will create a lockfile for pak, similar as is currently being done by conda. That lockfile can be used to recreate the exact R environment using pak.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions