{"id":14067437,"url":"https://github.com/analythium/openfaas-rstats-templates","last_synced_at":"2026-01-07T15:58:12.867Z","repository":{"id":45771648,"uuid":"232494132","full_name":"analythium/openfaas-rstats-templates","owner":"analythium","description":"OpenFaaS templates for R","archived":false,"fork":false,"pushed_at":"2022-07-16T05:57:40.000Z","size":269,"stargazers_count":19,"open_issues_count":3,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-19T16:46:42.885Z","etag":null,"topics":["faas","functions","functions-as-a-service","openfaas","plumber","r","rstats","templates"],"latest_commit_sha":null,"homepage":null,"language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/analythium.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-01-08T06:26:26.000Z","updated_at":"2025-03-22T10:35:07.000Z","dependencies_parsed_at":"2022-09-14T05:20:49.382Z","dependency_job_id":null,"html_url":"https://github.com/analythium/openfaas-rstats-templates","commit_stats":null,"previous_names":[],"tags_count":2,"template":true,"template_full_name":null,"purl":"pkg:github/analythium/openfaas-rstats-templates","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/analythium%2Fopenfaas-rstats-templates","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/analythium%2Fopenfaas-rstats-templates/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/analythium%2Fopenfaas-rstats-templates/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/analythium%2Fopenfaas-rstats-templates/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/analythium","download_url":"https://codeload.github.com/analythium/openfaas-rstats-templates/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/analythium%2Fopenfaas-rstats-templates/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267792592,"owners_count":24144929,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-29T02:00:12.549Z","response_time":2574,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["faas","functions","functions-as-a-service","openfaas","plumber","r","rstats","templates"],"created_at":"2024-08-13T07:05:35.645Z","updated_at":"2026-01-07T15:58:12.814Z","avatar_url":"https://github.com/analythium.png","language":"R","funding_links":[],"categories":["R"],"sub_categories":[],"readme":"# R (rstats) templates for OpenFaaS\n\n\u003cimg src=\"https://hub.analythium.io/assets/web/faastr.png\" align=\"right\" style=\"padding-left:10px;background-color:white;\" /\u003e\n\n\u003e [OpenFaaS](https://www.openfaas.com/) templates\n\u003e for the [R](https://www.r-project.org/) language.\n\n- [R (rstats) templates for OpenFaaS](#r-rstats-templates-for-openfaas)\n  - [Introduction](#introduction)\n    - [Parent image](#parent-image)\n    - [Watchdog type](#watchdog-type)\n    - [Server framework (for of-watchdog only)](#server-framework-for-of-watchdog-only)\n  - [Usage](#usage)\n    - [Setup](#setup)\n    - [Make a new function](#make-a-new-function)\n    - [Customize your function](#customize-your-function)\n  - [Contributing](#contributing)\n  - [License](#license)\n\n**Read the [R Templates blog post](https://www.openfaas.com/blog/r-templates/) and watch this [useR!2021 video](https://youtu.be/jLmE7jA-lHI) for a quick intro!**\n\n## Introduction\n\nThe `/template` folder contains the following OpenFaaS templates:\n\n| Template | Base image | Watchdog | Server framework |\n|----------|------------|----------|------------------|\n| [rstats-base](template/rstats-base) | rocker/r-base | classic | None (STDIO) |\n| [rstats-ubuntu](template/rstats-ubuntu) | rocker/r-ubuntu | classic | None (STDIO) |\n| [rstats-minimal](template/rstats-minimal) | rhub/r-minimal | classic | None (STDIO) |\n| [rstats-base-plumber](template/rstats-base-plumber) | rocker/r-base | of-watchdog | plumber |\n| [rstats-ubuntu-plumber](template/rstats-ubuntu-plumber) | rocker/r-ubuntu | of-watchdog | plumber |\n| [rstats-minimal-plumber](template/rstats-minimal-plumber) | rhub/r-minimal | of-watchdog | plumber |\n| [rstats-base-httpuv](template/rstats-base-httpuv) | rocker/r-base | of-watchdog | httpuv |\n| [rstats-ubuntu-httpuv](template/rstats-ubuntu-httpuv) | rocker/r-ubuntu | of-watchdog | httpuv |\n| [rstats-minimal-httpuv](template/rstats-minimal-httpuv) | rhub/r-minimal | of-watchdog | httpuv |\n| [rstats-base-beakr](template/rstats-base-beakr) | rocker/r-base | of-watchdog | beakr |\n| [rstats-ubuntu-beakr](template/rstats-ubuntu-beakr) | rocker/r-ubuntu | of-watchdog | beakr |\n| [rstats-minimal-beakr](template/rstats-minimal-beakr) | rhub/r-minimal | of-watchdog | beakr |\n| [rstats-base-fiery](template/rstats-base-fiery) | rocker/r-base | of-watchdog | fiery |\n| [rstats-ubuntu-fiery](template/rstats-ubuntu-fiery) | rocker/r-ubuntu | of-watchdog | fiery |\n| [rstats-minimal-fiery](template/rstats-minimal-fiery) | rhub/r-minimal | of-watchdog | fiery |\n| [rstats-base-ambiorix](template/rstats-base-ambiorix) | rocker/r-base | of-watchdog | ambiorix |\n| [rstats-ubuntu-ambiorix](template/rstats-ubuntu-ambiorix) | rocker/r-ubuntu | of-watchdog | ambiorix |\n| [rstats-minimal-ambiorix](template/rstats-minimal-ambiorix) | rhub/r-minimal | of-watchdog | ambiorix |\n\nThe templates differ with respect to:\n\n- R parent image,\n- watchdog type, and\n- the server framework used.\n\n### Parent image\n\n- Debian-based `rocker/r-base` Docker image from the [rocker](https://github.com/rocker-org/rocker/tree/master/r-base) project for bleeding edge,\n- Ubuntu-based `rocker/r-ubuntu` Docker image from the [rocker](https://github.com/rocker-org/rocker/tree/master/r-ubuntu) project for long term support (uses [RSPM](https://packagemanager.rstudio.com/client/) binaries),\n- Alpine-based `rhub/r-minimal` Docker image from the [r-hub](https://github.com/r-hub/r-minimal) project for smallest image sizes.\n\nSee the [Rocker](https://journal.r-project.org/archive/2017/RJ-2017-065/RJ-2017-065.pdf) and the [Rockerverse](https://journal.r-project.org/archive/2020/RJ-2020-007/RJ-2020-007.pdf) papers in the R Journal about the current state of the art regarding the use of container technology in R.\n\n### Watchdog type\n\n- The [classic watchdog](https://github.com/openfaas/classic-watchdog) is a tiny Golang webserver that marshals an HTTP request accepted on the API Gateway and to invoke your chosen application. This is the init process for your container. The classic watchdog passes in the HTTP request via STDIN and reads a HTTP response via STDOUT.\n- The _http mode_ of the [of-watchdog](https://github.com/openfaas/of-watchdog) provides more control over your HTTP responses (\"hot functions\", persistent connection pools, or caching).\n\nThe of-watchdog _http mode_ loads the handler as a small background web server.\nThe classic watchdog's forking mode would instead load this file for every invocation creating additional latency when loading packages, saved data, or trained models.\n\n### Server framework (for of-watchdog only)\n\nFrameworks are listed in the order of their dependence relationships:\n\n- [httpuv](https://CRAN.R-project.org/package=httpuv)\n  - [plumber](https://www.rplumber.io/)\n  - [fiery](https://CRAN.R-project.org/package=fiery)\n  - [beakr](https://CRAN.R-project.org/package=beakr)\n  - [ambiorix](https://ambiorix.john-coene.com/)\n\nMore server frameworks are being explored, such as the \n[Rserve](https://www.rforge.net/Rserve/) based [RestRserve](https://restrserve.org/),\nor the httpuv based [opencpu](https://www.opencpu.org/).\nSee [**ROADMAP**](https://github.com/analythium/openfaas-rstats-templates/issues/19) for details. **PRs are welcome!**\n\n## Usage\n\n### Setup\n\nIt is recommended to read the [OpenFaaS docs](https://docs.openfaas.com/) first\nand set up a local or remote [Kubernetes cluster](https://docs.openfaas.com/deployment/kubernetes/) or [faasd](https://docs.openfaas.com/deployment/faasd/) with\nOpenFaaS deployed. To get going quickly,\nfollow the official OpenFaaS [workshop](https://docs.openfaas.com/tutorials/workshop/), or enroll into the free\n[Introduction to Serverless on Kubernetes](https://www.edx.org/course/introduction-to-serverless-on-kubernetes) course.\n\n\u003e If you are looking for the smallest footprint (single node), the book [Serverless For Everyone Else](https://gumroad.com/a/494294131/fKOcw) by Alex Ellis is highly recommended.\n\nSee recommended [setup steps](https://github.com/analythium/openfaas-rstats-examples) for the R template examples.\n\n### Make a new function\n\nUse the [`faas-cli`](https://github.com/openfaas/faas-cli) and pull R templates:\n\n```bash\nfaas-cli template pull https://github.com/analythium/openfaas-rstats-templates\n```\n\nNow `faas-cli new --list` should give you a list with the available `rstats-*` templates.\n\nCreate a new function called `hello-rstats`:\n\n```bash\nexport OPENFAAS_PREFIX=\"\" # Populate with your Docker Hub username\nfaas-cli new --lang rstats-base hello-rstats --prefix=$OPENFAAS_PREFIX\n```\n\nthe `OPENFAAS_PREFIX` means a user or organization on e.g. Docker Hub where\nyou have push privileges; don't forget to log in to your registry using `docker login`.\n\nYour folder now should contain the following:\n\n```bash\nhello-rstats/handler.R\nhello-rstats/DESCRIPTION\nhello-rstats.yml\n```\n\nThe `hello-rstats/handler.R` file does the heavy lifting by executing the desired\nfunctionality. `hello-rstats/DESCRIPTION` lists the dependencies for the handler.\nThe `hello-rstats.yml` is the stack file used to configure functions\n(read more [here](https://docs.openfaas.com/reference/yaml/)).\n\nYou can build, push, and deploy the `hello-rstats` function using:\n\n```bash\nfaas-cli up -f hello-rstats.yml\n```\n\n`faas-cli up` is a [shorthand](https://docs.openfaas.com/cli/templates/)\nfor automating `faas-cli build`, `faas-cli push`, and `faas-cli deploy`.\n\nOnce the function is deployed, you can test it in the UI\n(e.g. at `OPENFAAS_URL/ui/`) or using curl:\n\n```bash\ncurl $OPENFAAS_URL/function/hello-rstats -d '[\"World\"]'\n```\n\nBoth should give the JSON output `\"Hello World!\"`.\n\n### Customize your function\n\nYou can now edit `hello-rstats/handler.R` to your liking.\nDon't forget to add dependencies to the `hello-rstats/DESCRIPTION` file.\n\nSee [worked examples](https://github.com/analythium/openfaas-rstats-examples) for different use cases.\nRead more about the [structure of the templates](template/README.md) if advanced tuning is required, e.g. by editing the `Dockerfile`, etc.\n\nThe template installs dependencies specified in the `DESCRIPTION` file\nin this order:\n\n1. `SystemRequirements:` list OS specific system requirements here, comma separated, these are then installed by the OS's package manager,\n2. CRAN packages listed in `Depends:`, `Imports:`, `LinkingTo:` fields are installed by `remotes::install_deps()`,\n3. `Remotes:` fields are installed according to [remotes](https://cran.r-project.org/web/packages/remotes/vignettes/dependencies.html) specifications, make sure to list the package in `Imports:` as well, the location specified in `Remotes:` will be used to get the package from,\n4. `VersionedPackages:` this field can be used to pin package versions using `remotes::install_version()`, do not list these packages in other fields (spaces after operators and after commas inside parentheses are important, e.g. `devtools (1.11.0), mypackage (\u003e= 1.12.0, \u003c 1.14)`).\n\nYou can also modify the `Dockerfile` in the template if specific\nR version or further customization is needed. The R parent image is defined as a Docker `ARG` called `R_IMAGE`that you can override. I.e. use the versioned Rocker Debian image using [custom build arguments](https://docs.openfaas.com/cli/build/#30-pass-custom-build-arguments):\n\n```bash\nfaas-cli new --lang rstats-base-plumber hello-rstats-2 --prefix=$OPENFAAS_PREFIX\n\nfaas-cli build -f hello-rstats-2.yml --build-arg R_IMAGE=rocker/r-base:4.0.0\n```\n\nYou can also edit the [stack YAML file](https://docs.openfaas.com/reference/yaml/#function-build-args-build-args):\n\n```yaml\n...\nfunctions:\n  hello-rstats-2:\n    lang: rstats-base-plumber\n...\n    build_args:\n      R_IMAGE: rocker/r-base:4.0.0\n```\n\nSystem requirements for the same package might be different across\nLinux distributions. This is a grey area of the R package ecosystem, see these links for help:\n\n- [rstudio/r-system-requirements](https://github.com/rstudio/r-system-requirements)\n- [r-hub/sysreqsdb](https://github.com/r-hub/sysreqsdb)\n- [r-universe/](https://r-universe.dev/)\n- [maketools](https://cran.r-project.org/web/packages/maketools/vignettes/sysdeps.html) to determine run-time and build-time dependencies\n\n## Contributing\n\nPlease read the [code of conduct](CODE_OF_CONDUCT.md).\n[DCO](https://en.wikipedia.org/wiki/Developer_Certificate_of_Origin) is required,\nsign commits that are submitted as PR (`git commit -s -m \"Commit message\"`).\n\n## License\n\nCopyright (c) 2020, Peter Solymos, Analythium Solutions Inc. [MIT](LICENSE.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanalythium%2Fopenfaas-rstats-templates","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanalythium%2Fopenfaas-rstats-templates","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanalythium%2Fopenfaas-rstats-templates/lists"}