signaturescience / pracpac

Practical R Packaging with Docker
https://signaturescience.github.io/pracpac/
Other
25 stars 0 forks source link

Build Docker without R #102

Open stephenturner opened 1 year ago

stephenturner commented 1 year ago

Opening this but feel free to close @vpnagraj.

Building a Docker image from a Dockerfile created with pracac requires R to be installed on the host system. This may not always be desirable, in the case where you'd like to distribute the source code to others to build who may not have R installed for building the package targz.

An alternative approach could copy relevant R package source folders into the container and use devtools to build:

# FROM whatever
# RUN Rscript -e install deps, etc.

# Install devtools: not a pkg dep, but needed to install in the docker build
RUN Rscript -e 'BiocManager::install(c("devtools"))'

# Copy the source into the root of the container
RUN mkdir -p /src
COPY DESCRIPTION NAMESPACE .Rbuildignore /src
COPY R /src/R
COPY man /src/man
COPY inst /src/inst
COPY data /src/data
COPY vignettes /src/vignettes

# Build the R package
RUN Rscript -e 'devtools::install("/src", dependencies=FALSE)'

# Continue COPYing and add ENTRYPOINT, etc.

I'm okay closing this issue as well -- pracpac is meant to be used by package developers, who in every case will have R installed on their system. The thought here is for downstream consumers who may not, who'd like to build the image without a pre-build source tar.gz.

stephenturner commented 1 year ago

(That dependencies=FALSE is something from one of my own builds -- you may want to remove this, but needs some experimentation with deps of deps, etc)