analythium / openfaas-rstats-templates

OpenFaaS templates for R
MIT License
20 stars 1 forks source link

r-minimal build dependencies #38

Closed psolymos closed 3 years ago

psolymos commented 3 years ago

Add BuildRequirements to DESCRIPTION file (similar to r-hub's install script) to identify dependencies that can be removed after R package installation. gcc musl-dev g++ can be added to Dockerfile, maybe even gfortran linux-headers:

# Istall SystemRequirements for handler.R from DESCRIPTION
RUN R -q -e 'source("/usr/local/bin/install.R"); install$sysreqs()'
RUN echo requirements.txt
RUN apk update
RUN apk add --no-cache gcc musl-dev g++ gfortran linux-headers
RUN xargs -a requirements.txt apk add

# Install packages (incl. remotes) for handler.R from DESCRIPTION
RUN R -q -e 'remotes::install_deps()'

# Install VersionedPackages for handler.R from DESCRIPTION
RUN R -q -e 'source("/usr/local/bin/install.R"); install$versioned()'

# Clean up
RUN apk del gcc musl-dev g++ gfortran linux-headers
RUN rm -rf /var/cache/apk/*
RUN rm requirements.txt
psolymos commented 3 years ago

No need for additional entry in DESCRIPTION, just add these packages and the delete in the template.