analythium / openfaas-rstats-templates

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

System dependencies as build options/arguments #10

Closed psolymos closed 4 years ago

psolymos commented 4 years ago

System dependencies should be added to the YAML file as build option or passed as build argument.

For this, add ADDITIONAL_PACKAGE ARG to the Dockerfile.

https://docs.openfaas.com/cli/build/#10-apply-build-options

psolymos commented 4 years ago

Decided to go with the build argument in the README file, but as the docs say, it is less preferred when e.g. multiple functions are described in the same stack YAML file.

When going the build option route, here is the recipe:

edit the /templates/<template-name>/template.yml file:

language: rstats
fprocess: Rscript index.R
build_options:
  - name: dev
    packages:
      - git-core
      - libssl-dev
      - libcurl4-gnutls-dev

Then call faas-cli new then

faas-cli up -f hello-rstats.yml --build-option dev

Note: both build options and build arguments have been tested and are working as expected: installing system dependency packages during build.

psolymos commented 4 years ago

Should we support different build options out of the box? E.g. tidyverse, geospatial (as in rocker equivalents)?

Not: it is easier to change the base image in the /templates/<template-name>/Dockerfile (e.g. rocker/r-base to rocker/geospatial).