{"id":14067586,"url":"https://github.com/virtualstaticvoid/heroku-docker-r","last_synced_at":"2026-03-01T13:41:08.912Z","repository":{"id":44342864,"uuid":"48537247","full_name":"virtualstaticvoid/heroku-docker-r","owner":"virtualstaticvoid","description":"Heroku R Docker Image - Makes deploying R on Heroku easy","archived":false,"fork":false,"pushed_at":"2024-12-30T10:28:51.000Z","size":16065,"stargazers_count":34,"open_issues_count":2,"forks_count":11,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-30T02:59:11.408Z","etag":null,"topics":["docker","docker-images","heroku","heroku-buildpack","heroku-deployment","heroku-docker","packrat","plumber","plumber-applications","r","renv","rproject","shiny","shiny-applications"],"latest_commit_sha":null,"homepage":"","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/virtualstaticvoid.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2015-12-24T10:00:22.000Z","updated_at":"2024-12-29T13:46:37.000Z","dependencies_parsed_at":"2025-07-30T02:44:16.122Z","dependency_job_id":"b1ade593-dd13-45ec-829d-69b0ca09712a","html_url":"https://github.com/virtualstaticvoid/heroku-docker-r","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/virtualstaticvoid/heroku-docker-r","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virtualstaticvoid%2Fheroku-docker-r","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virtualstaticvoid%2Fheroku-docker-r/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virtualstaticvoid%2Fheroku-docker-r/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virtualstaticvoid%2Fheroku-docker-r/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/virtualstaticvoid","download_url":"https://codeload.github.com/virtualstaticvoid/heroku-docker-r/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virtualstaticvoid%2Fheroku-docker-r/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29970518,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-01T13:32:00.443Z","status":"ssl_error","status_checked_at":"2026-03-01T13:32:00.084Z","response_time":124,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["docker","docker-images","heroku","heroku-buildpack","heroku-deployment","heroku-docker","packrat","plumber","plumber-applications","r","renv","rproject","shiny","shiny-applications"],"created_at":"2024-08-13T07:05:40.574Z","updated_at":"2026-03-01T13:41:08.894Z","avatar_url":"https://github.com/virtualstaticvoid.png","language":"R","readme":"# Heroku R Docker Image\n\n[![Build \u0026 Publish](https://github.com/virtualstaticvoid/heroku-docker-r/actions/workflows/build-publish.yml/badge.svg)](https://github.com/virtualstaticvoid/heroku-docker-r/actions/workflows/build-publish.yml)\n\nThis is the docker image for applications which use [R][rproject] for statistical computing\nand [CRAN][cran] for R packages, running on [Heroku][heroku].\n\nThis project is compatible with the [heroku-buildpack-r][buildpackr] so that it is possible to\nmigrate your existing Heroku R applications and deploy them using the new Heroku\n[`container`][container_stack] stack, however there are some caveats if multiple buildpacks\nwere used together with [heroku-buildpack-r][buildpackr].\n\nThe new stack alleviates many of the complexities and issues with the R buildpack.\n\nPre-built docker images are published on [GitHub Container Registry][ghcr], and are based off the\nofficial [Ubuntu][ubuntu] docker images. Previous versions were published to [Docker Hub][dockerhub].\n\nSupport has been added for [packrat][packrat] and [renv][renv] package managers.\n\n**NOTE**: Docker *is not required* to be installed on your machine, unless you need to build\nand run the images locally. For the most common use cases, you can probably use the default\nconfiguration so it won't be necessary to have docker installed.\n\n## Usage\n\n### Shiny Applications\n\nThese steps are for [Shiny][shiny] applications.\n\nIn your Shiny application source's root directory:\n\n* Create a `Dockerfile` file and insert the following content.\n\n  ```\n  FROM ghcr.io/virtualstaticvoid/heroku-docker-r:shiny\n  ENV PORT=8080\n  CMD [\"/usr/bin/R\", \"--no-save\", \"--gui-none\", \"-f\", \"/app/run.R\"]\n  ```\n\n* Create a `heroku.yml` file and insert the following content.\n\n  ```yaml\n  build:\n    docker:\n      web: Dockerfile\n  ```\n\n* Commit the changes, using `git` as per usual.\n\n  ```bash\n  git add Dockerfile heroku.yml\n  git commit -m \"Using heroku-docker-r FTW\"\n  ```\n\n* Create the Heroku application with the `container` stack\n\n  ```bash\n  heroku create --stack=container\n  ```\n\n  Or configure an existing application to use the `container` stack.\n\n  ```bash\n  heroku stack:set container\n  ```\n\n* Deploy your application to Heroku, replacing `\u003cbranch\u003e` with your branch. E.g. `master`.\n\n  ```bash\n  git push heroku \u003cbranch\u003e\n  ```\n\n* Scale the web dyno\n\n  ```bash\n  heroku scale web=1\n  ```\n\nSee [heroku-docker-r-shiny-app][shiny_app] for an example application.\n\n### Plumber Applications\n\nThese steps are for [Plumber][plumber] applications.\n\nIn your Plumber application source's root directory:\n\n* Create a `Dockerfile` file and insert the following content.\n\n  ```\n  FROM ghcr.io/virtualstaticvoid/heroku-docker-r:plumber\n  ENV PORT=8080\n  CMD [\"/usr/bin/R\", \"--no-save\", \"--gui-none\", \"-f\", \"/app/app.R\"]\n  ```\n\n* Create a `heroku.yml` file and insert the following content.\n\n  ```yaml\n  build:\n    docker:\n      web: Dockerfile\n  ```\n\n* Commit the changes, using `git` as per usual.\n\n  ```bash\n  git add Dockerfile heroku.yml\n  git commit -m \"Using heroku-docker-r FTW\"\n  ```\n\n* Create the Heroku application with the `container` stack\n\n  ```bash\n  heroku create --stack=container\n  ```\n\n  Or configure an existing application to use the `container` stack.\n\n  ```bash\n  heroku stack:set container\n  ```\n\n* Deploy your application to Heroku, replacing `\u003cbranch\u003e` with your branch. E.g. `master`.\n\n  ```bash\n  git push heroku \u003cbranch\u003e\n  ```\n\n* Scale the web dyno\n\n  ```bash\n  heroku scale web=1\n  ```\n\nSee [heroku-docker-r-plumber-app][plumber_app] for an example application.\n\n### Other R Applications\n\nThese steps are for console and other types of R applications.\n\nIn your R application source's root directory:\n\n* Create a `Dockerfile` file and insert the following content.\n\n  ```\n  FROM ghcr.io/virtualstaticvoid/heroku-docker-r:build\n  CMD [\"/usr/bin/R\", \"--no-save\", \"-f\", \"/app/\u003cR-program\u003e\"]\n  ```\n\n  Change `\u003cR-program\u003e` to the main R program you want to have executed. E.g. `app.R`.\n\n* Create a `heroku.yml` file and insert the following content.\n\n  ```yaml\n  build:\n    docker:\n      app: Dockerfile\n  ```\n\n* Commit the changes, using `git` as per usual.\n\n  ```bash\n  git add Dockerfile heroku.yml\n  git commit -m \"Using heroku-docker-r FTW\"\n  ```\n\n* Create the Heroku application with the `container` stack\n\n  ```bash\n  heroku create --stack=container\n  ```\n\n  Or configure an existing application to use the `container` stack.\n\n  ```bash\n  heroku stack:set container\n  ```\n\n* Deploy your application to Heroku, replacing `\u003cbranch\u003e` with your branch. E.g. `master`.\n\n  ```bash\n  git push heroku \u003cbranch\u003e\n  ```\n\n* Run the application\n\n  ```bash\n  heroku run app\n  ```\n\n### Applications with Additional Dependencies\n\nFor R applications which have additional dependencies, the `container` stack gives you much\nmore flexibility with the [`Dockerfile`][builder] than was previously available in the R buildpack;\nsuch as for installing dependencies from other sources, from `deb` files or by compiling\nlibraries from scratch, or using docker's [multi-stage builds][multistage].\nIt also provides greater control over the runtime directory layout and execution environment.\n\nTo make it easier for project authors to manage dependencies and provide backward compatibility\nwith the [heroku-buildpack-r][buildpackr] without the need for Docker to be installed, the\nfollowing functionality is provided:\n\nIn each of the following examples, Docker's [`ONBUILD`][onbuild] method is used to execute\nthe step when the respective file is detected.\n\n* `init.R`\n\n  Maintaining compatibility with the [heroku-buildpack-r][buildpackr], the `init.R` file is\n  still supported and is used to install any R packages or config R as necessary.\n\n  In addition, an R helper function, called `helper.installPackages` is provided to simplify\n  installing R packages. The function takes a list of R package names to install.\n\n  During the deployment process, the existence of the `./init.R` file will cause the\n  script to be executed in R.\n\n  E.g. This example installs the `gmp` R package.\n\n  ```R\n  # install additional packages, using helper function\n  helpers.installPackages(\"gmp\")\n  ```\n\n* `Aptfile`\n\n  Create a text file, called `Aptfile` in your project's root directory, which contains the\n  Ubuntu package names to install.\n\n  During the deployment process, the existence of the `./Aptfile` file will cause the packages\n  to be installed using `apt-get install ...`.\n\n  E.g. This example `Aptfile` installs the GNU Multiple Precision Arithmetic library\n  and supporting libraries.\n\n  ```\n  libgmp10\n  libgmp3-dev\n  libmpfr4\n  libmpfr-dev\n  ```\n\n  This is based on the same technique as used by the [heroku-buildpack-apt][buildpack_apt] buildpack.\n\n* `onbuild`\n\n  Create a Bash script file, called `onbuild` in your project's root directory, containing the \n  commands you need to install any dependencies, language runtimes and perform configuration \n  tasks as needed.\n\n  During the deployment process, the existence of the `./onbuild` file will cause it to be \n  executed in Bash.\n\n  E.g. This example `onbuild` file installs Ubuntu packages.\n\n  ```bash\n  #!/bin/bash\n  set -e # fail fast\n\n  # refresh package index\n  apt-get update -q\n\n  # install \"packages\"\n  apt-get install -qy packages-names\n\n  # reduce the image size by removing unnecessary Apt files\n  apt-get autoclean\n  ```\n\n  NOTE: Change \"packages-names\" to the list of packages you wish to install.\n\n  See [Java][examples-java], [Python][examples-python] and [Ruby][examples-ruby] for examples \n  of using the `onbuild` Bash script.\n\n* `packrat`\n\n  If you want to install and manage R packages more reliably, you can use `packrat` to manage them.\n  Please see the [packrat][packrat] documentation for further details.\n\n  During the deployment process, the existence of the `./packrat/init.R` file will cause Packrat \n  to be bootstraped and the referenced packages installed.\n\n  It is recommended to include a `.dockerignore` file in your project's root directory, in \n  order to exclude unnecessary directories/files being included from the `packrat` subdirectory.\n\n  E.g. Example `.dockerignore`\n\n  ```\n  packrat/lib*/\n  ```\n\n  NOTE: `packrat` has been soft-deprecated in favour of `renv`.\n\n* `renv`\n\n  If you want to install and manage R packages more reliably, you can use `renv` to manage them. \n  This is the recommended way to manage your R packages. Please see the [renv][renv] \n  documentation for further details.\n\n  During the deployment process, the existence of the `./renv/activate.R` file will cause \n  `renv` to be bootstraped and the referenced packages installed.\n\n  It is recommended to include a `.dockerignore` file in your project's root directory, in \n  order to exclude unnecessary directories/files being included from the `renv` subdirectory.\n\n  E.g. Example `.dockerignore`\n\n  ```\n  renv/library/\n  renv/python/\n  renv/staging/\n  ```\n\n### Multi-Language Applications\n\nFor applications which use another language, such as Java, Python or Ruby to interface with \nR, the `container` stack gives you much more flexibility and control over the environment, \nhowever the onus is on the developer to configure the language stack within the docker \ncontainer instead of with mulitple buildpacks.\n\nIn each example, the language runtime can be installed via the use of an `onbuild` Bash \nscript, which must be in the root of the project directory, and which is invoked during \nthe deployment process.\n\nThis shell script can run installations such as using `apt-get` for example, or any other \ncommands to setup language support and perform configuration as needed.\n\nThere are of course many permutations possible, so some [examples][examples] are provided \nto help you get the idea:\n\n* [Java][examples-java]\n\n  The Java example installs the OpenJDK, configures R accordingly and compiles the \n  project's Java source files.\n\n* [Python][examples-python]\n\n  In the Python example, the `onbuild` installs the Python runtime and installs the \n  project dependenecies using `pip`.\n\n* [Ruby][examples-ruby]\n\n  The Ruby example installs the runtime and then installs the project dependencies using `bundler`.\n\n## Existing R Applications\n\nFor R applications which use the [heroku-buildpack-r][buildpackr], this project provides \nbackward compatibility so that you can continue to enjoy the benefit of using Heroku to \ndeploy and run your application, without much change.\n\nThe process continues to use your `init.R` file in order to install any packages your \napplication requires. Furthermore, the `Aptfile` continues to be supported in order to \ninstall additional binary dependencies.\n\nIt is worth nothing that use of [multiple buildpacks][multibuildpack] is not supported \n_nor needed_ on the `container` stack, so you may have some rework to do if you made \nuse of this feature.\n\nPlease see the [MIGRATING](MIGRATING.md) guide for details on how to migrate your \nexisting R application.\n\n## Speeding Up Deploys\n\nSince the container stack makes use of docker together with a [`Dockerfile`][builder] \nto define the image, it is possible to speed up deployments by pre-building them.\n\n**NOTE:** This requires having docker installed and an account on [Docker Hub][dh] or \nother Heroku accessible container registry.\n\nAn example of how this is done can be found in the [\"speedy\"][examples-speedy] example application.\n\n## Versions\n\nThe following versions for [`ghcr.io/virtualstaticvoid/heroku-docker-r`][ghcr-tags] are\navailable on [GitHub Container Registry][ghcr], including:\n\n| Ubuntu Version | R Version | Base Tag      | Build Tag     | Shiny Tag     | Plumber Tag     |\n|----------------|-----------|---------------|---------------|---------------|-----------------|\n| `22.04`        | `4.4.2`   | `latest`      | `build`       | `shiny`       | `plumber`       |\n| `22.04`        | `4.4.2`   |               | `4.4.2-build` | `4.4.2-shiny` | `4.4.2-plumber` |\n| `22.04`        | `4.3.3`   |               | `4.3.3-build` | `4.3.3-shiny` | `4.3.3-plumber` |\n| `22.04`        | `4.2.3`   |               | `4.2.3-build` | `4.2.3-shiny` | `4.2.3-plumber` |\n| `22.04`        | `4.2.2`   |               | `4.2.2-build` | `4.2.2-shiny` | `4.2.2-plumber` |\n| `22.04`        | `4.2.1`   |               | `4.2.1-build` | `4.2.1-shiny` | `4.2.1-plumber` |\n\nPrevious versions for [`virtualstaticvoid/heroku-docker-r`][tags] are available \non [Docker Hub][dockerhub], including:\n\n| Ubuntu Version | R Version | Build Tag     | Shiny Tag     | Plumber Tag     |\n|----------------|-----------|---------------|---------------|-----------------|\n| `20.04`        | `4.1.0`   | `4.1.0-build` | `4.1.0-shiny` | `4.1.0-plumber` |\n| `20.04`        | `4.0.5`   | `4.0.5-build` | `4.0.5-shiny` | `4.0.5-plumber` |\n| `20.04`        | `4.0.2`   | `4.0.2-build` | `4.0.2-shiny` | `4.0.2-plumber` |\n| `20.04`        | `4.0.1`   | `4.0.1-build` | `4.0.1-shiny` | `4.0.1-plumber` |\n| `20.04`        | `4.0.0`   | `4.0.0-build` | `4.0.0-shiny` | `4.0.0-plumber` |\n| `20.04`        | `3.6.3`   | `3.6.3-build` | `3.6.3-shiny` | `3.6.3-plumber` |\n| `20.04`        | `3.6.2`   | `3.6.2-build` | `3.6.2-shiny` |                 |\n| `20.04`        | `3.5.2`   | `3.5.2-build` | `3.5.2-shiny` |                 |\n| `20.04`        | `3.4.4`   | `3.4.4-build` | `3.4.4-shiny` |                 |\n\n## Examples\n\nThe [examples][examples] repository contains various R applications which can be used as templates.\n\nThey illustrate usage of the docker image and the configuration necessary to deploy to Heroku.\n\n* [Shiny][examples-shiny] - An example Shiny application\n* [Plumber][examples-plumber] - An example Plumber application\n* [Packrat][examples-packrat] - Illustrates using packrat\n* [Renv][examples-renv] - Illustrates using renv\n* [Python][examples-python] - Shows interoperability between Python and R\n* [Java][examples-java] - Shows interoperability between Java and R\n* [Ruby][examples-ruby] - Shows interoperability between Ruby and R\n\n## Credits\n\n* Original [`heroku-buildpack-r`][buildpackr] for \"buildpack\" API.\n* Snippets from the [`rstudio/r-docker`][r-docker] project.\n* Snippets from the [`rstudio/r-builds`][r-builds] project.\n\n## License\n\nMIT License. Copyright (c) 2018 Chris Stefano. See [MIT_LICENSE](MIT_LICENSE) for details.\n\n## Additional Information\n\nR is \"GNU S\", a freely available language and environment for statistical computing and \ngraphics which provides a wide variety of statistical and graphical techniques: linear \nand nonlinear modelling, statistical tests, time series analysis, classification, \nclustering, etc. Please consult the [R project homepage][rproject] for further information.\n\n[CRAN][cran] is a network of FTP and Web Servers around the world that store identical, \nup-to-date, versions of code and documentation for R.\n\n[builder]: https://docs.docker.com/engine/reference/builder\n[buildpack_apt]: https://elements.heroku.com/buildpacks/heroku/heroku-buildpack-apt\n[buildpackr]: https://github.com/virtualstaticvoid/heroku-buildpack-r\n[container_stack]: https://devcenter.heroku.com/articles/container-registry-and-runtime\n[cran]: http://cran.r-project.org\n[dh]: https://hub.docker.com\n[dockerhub]: https://hub.docker.com/repository/docker/virtualstaticvoid/heroku-docker-r\n[examples-console]: https://github.com/virtualstaticvoid/heroku-docker-r-examples/tree/master/console\n[examples-java]: https://github.com/virtualstaticvoid/heroku-docker-r-examples/tree/master/java\n[examples-packrat]: https://github.com/virtualstaticvoid/heroku-docker-r-examples/tree/master/packrat\n[examples-plumber]: https://github.com/virtualstaticvoid/heroku-docker-r-examples/tree/master/plumber\n[examples-python]: https://github.com/virtualstaticvoid/heroku-docker-r-examples/tree/master/python\n[examples-renv]: https://github.com/virtualstaticvoid/heroku-docker-r-examples/tree/master/renv\n[examples-ruby]: https://github.com/virtualstaticvoid/heroku-docker-r-examples/tree/master/ruby\n[examples-shiny]: https://github.com/virtualstaticvoid/heroku-docker-r-examples/tree/master/shiny\n[examples-speedy]: https://github.com/virtualstaticvoid/heroku-docker-r-examples/tree/master/speedy\n[examples]: https://github.com/virtualstaticvoid/heroku-docker-r-examples\n[ghcr-tags]: https://github.com/users/virtualstaticvoid/packages/container/package/heroku-docker-r\n[ghcr]: https://github.com/virtualstaticvoid/heroku-docker-r/packages\n[heroku]: https://heroku.com\n[multibuildpack]: https://devcenter.heroku.com/articles/using-multiple-buildpacks-for-an-app\n[multistage]: https://docs.docker.com/develop/develop-images/multistage-build\n[onbuild]: https://docs.docker.com/engine/reference/builder/#onbuild\n[packrat]: http://rstudio.github.io/packrat\n[plumber]: https://www.rplumber.io\n[plumber_app]: https://github.com/virtualstaticvoid/heroku-docker-r-plumber-app\n[r-builds]: https://github.com/rstudio/r-builds\n[r-docker]: https://github.com/rstudio/r-docker\n[renv]: http://rstudio.github.io/renv\n[rproject]: http://www.r-project.org\n[shiny]: https://shiny.rstudio.com\n[shiny_app]: https://github.com/virtualstaticvoid/heroku-docker-r-shiny-app\n[tags]: https://hub.docker.com/repository/docker/virtualstaticvoid/heroku-docker-r/tags\n[ubuntu]: https://hub.docker.com/repository/ubuntu\n","funding_links":[],"categories":["R"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvirtualstaticvoid%2Fheroku-docker-r","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvirtualstaticvoid%2Fheroku-docker-r","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvirtualstaticvoid%2Fheroku-docker-r/lists"}