{"id":13858108,"url":"https://github.com/ThinkR-open/dockerfiler","last_synced_at":"2025-07-13T23:31:12.919Z","repository":{"id":37481561,"uuid":"120228699","full_name":"ThinkR-open/dockerfiler","owner":"ThinkR-open","description":"Easy Dockerfile Creation from R","archived":false,"fork":false,"pushed_at":"2025-06-21T22:46:49.000Z","size":304,"stargazers_count":183,"open_issues_count":21,"forks_count":27,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-07-12T16:04:38.044Z","etag":null,"topics":["golemverse","hacktoberfest","hacktoberfest-accepted"],"latest_commit_sha":null,"homepage":"https://thinkr-open.github.io/dockerfiler/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ThinkR-open.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE","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":"2018-02-04T22:22:00.000Z","updated_at":"2025-07-03T11:09:58.000Z","dependencies_parsed_at":"2023-02-10T14:00:53.977Z","dependency_job_id":"1b9677cb-ef72-4a7e-934f-4eff16093559","html_url":"https://github.com/ThinkR-open/dockerfiler","commit_stats":{"total_commits":57,"total_committers":10,"mean_commits":5.7,"dds":"0.42105263157894735","last_synced_commit":"e40f804e9728afb9bb5a8c52d965c9ac4a8fd58a"},"previous_names":["colinfay/dockerfiler"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/ThinkR-open/dockerfiler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThinkR-open%2Fdockerfiler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThinkR-open%2Fdockerfiler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThinkR-open%2Fdockerfiler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThinkR-open%2Fdockerfiler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ThinkR-open","download_url":"https://codeload.github.com/ThinkR-open/dockerfiler/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThinkR-open%2Fdockerfiler/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265074169,"owners_count":23707259,"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","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":["golemverse","hacktoberfest","hacktoberfest-accepted"],"created_at":"2024-08-05T03:01:56.931Z","updated_at":"2025-07-13T23:31:12.911Z","avatar_url":"https://github.com/ThinkR-open.png","language":"R","funding_links":[],"categories":["R","Containerization 🛍"],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r setup, include = FALSE}\nknitr::opts_chunk$set(\n  eval = FALSE,\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n\n\u003c!-- badges: start --\u003e\n[![R-CMD-check](https://github.com/ThinkR-open/dockerfiler/workflows/R-CMD-check/badge.svg)](https://github.com/ThinkR-open/dockerfiler/actions)\n[![Coverage status](https://codecov.io/gh/ThinkR-open/dockerfiler/branch/master/graph/badge.svg)](https://app.codecov.io/github/ThinkR-open/dockerfiler?branch=master)\n\u003c!-- badges: end --\u003e\n\n\n# `{dockerfiler}`\n\nThe goal of `{dockerfiler}` is to provide an easy way to create Dockerfiles from R.\n\n## About\n\nYou're reading the doc about version :\n\n```{r eval = TRUE}\ndesc::desc_get_version()\n```\n\n## Installation\n\nYou can install dockerfiler from GitHub with:\n\n```{r gh-installation, eval = FALSE}\n# install.packages(\"remotes\")\nremotes::install_github(\"ThinkR-open/dockerfiler\")\n```\n\nOr from CRAN with :\n\n```{r, eval = FALSE}\ninstall.packages(\"dockerfiler\")\n```\n\n## Basic worflow\n\nBy default, Dockerfiles are created with `FROM \"rocker/r-base\"`.\n\nYou can set another FROM in `new()`\n\n```{r}\nlibrary(dockerfiler)\n# Create a dockerfile template\nmy_dock \u003c- Dockerfile$new()\nmy_dock$MAINTAINER(\"Colin FAY\", \"contact@colinfay.me\")\n```\n\nAdd comments to your Dockerfile\n\n```{r}\nmy_dock$COMMENT(\"Install required R package.\")\n```\n\nWrap your raw R Code inside the `r()` function to turn it into a bash command with `R -e`.\n\n```{r}\nmy_dock$RUN(r(install.packages(\"attempt\", repo = \"http://cran.irsn.fr/\")))\n```\n\nClassical Docker stuffs:\n\n```{r}\nmy_dock$COMMENT(\"Copy Plumber API and main script to container.\")\nmy_dock$RUN(\"mkdir /usr/scripts\")\nmy_dock$RUN(\"cd /usr/scripts\")\nmy_dock$COPY(\"plumberfile.R\", \"/usr/scripts/plumber.R\")\nmy_dock$COPY(\"torun.R\", \"/usr/scripts/torun.R\")\nmy_dock$COMMENT(\"Expose the API port and run the main script when the container starts.\")\nmy_dock$EXPOSE(8000)\nmy_dock$CMD(\"Rscript /usr/scripts/torun.R \")\n```\n\nSee your Dockerfile :\n\n```{r}\nmy_dock\n```\n\nIf you've made a mistake in your script, you can switch lines with the `switch_cmd` method. This function takes as arguments the positions of the two cmd you want to switch :\n\n```{r}\n# Switch line 8 and 7\nmy_dock$switch_cmd(8, 7)\nmy_dock\n```\n\nYou can also remove a cmd with `remove_cmd`:\n\n```{r}\nmy_dock$remove_cmd(8)\nmy_dock\n```\n\nThis also works with a vector:\n\n```{r}\nmy_dock$remove_cmd(5:7)\nmy_dock\n```\n\n`add_after` add a command after a given line.\n\n```{r}\nmy_dock$add_after(\n  cmd = \"RUN R -e 'remotes::install_cran(\\\"rlang\\\")'\",\n  after = 3\n)\n```\n\n\nSave your Dockerfile:\n\n```{r eval = FALSE}\nmy_dock$write()\n```\n\n\n## Multi-stage dockerfile\n\nHere is an example of generating a multi-stage Dockerfile directly from R: we create two Dockerfile objects, one for the build stage (builder) and one for the final stage (final), and then merge them into a single file.\n\n```{r}\nstage_1 \u003c- Dockerfile$new(\n  FROM = \"alpine\",AS =\"builder\"\n)\nstage_1$RUN('echo \"Hi from builder\" \u003e /coucou.txt')\n\nstage_2 \u003c- Dockerfile$new(\n  FROM = \"ubuntu\", AS = \"final\"\n)\nstage_2$COMMENT(\"copy /coucou.txt from builder to /truc.txt in final\")\nstage_2$COPY(from = \"/coucou\",to = \"/truc.txt\",force = TRUE, stage =\"builder\")\nstage_2$RUN( \"cat /truc.txt\")\n\nstage_1$write()\nstage_2$write(append = TRUE)\n#file.edit(\"Dockerfile\")\n```\n\n\n\n## Create a Dockerfile from a DESCRIPTION\n\nYou can use a DESCRIPTION file to create a Dockerfile that installs the dependencies and the package.\n\n```{r}\nmy_dock \u003c- dock_from_desc(\"DESCRIPTION\")\nmy_dock\n\nmy_dock$CMD(r(library(dockerfiler)))\n\nmy_dock$add_after(\n  cmd = \"RUN R -e 'remotes::install_cran(\\\"rlang\\\")'\",\n  after = 3\n)\nmy_dock\n```\n\n## Create a Dockerfile from renv.lock\n\n- Create renv.lock\n```{r, message=FALSE, results='hide'}\ndir_build \u003c- tempfile(pattern = \"renv\")\ndir.create(dir_build)\n\n# Create a lockfile\nthe_lockfile \u003c- file.path(dir_build, \"renv.lock\")\ncustom_packages \u003c- c(\n  # attachment::att_from_description(),\n  \"renv\",\n  \"cli\",\n  \"glue\",\n  \"golem\",\n  \"shiny\",\n  \"stats\",\n  \"utils\",\n  \"testthat\",\n  \"knitr\"\n)\nrenv::snapshot(\n  packages = custom_packages,\n  lockfile = the_lockfile,\n  prompt = FALSE\n)\n```\n\n- Build Dockerfile\n```{r}\nmy_dock \u003c- dock_from_renv(\n  lockfile = the_lockfile,\n  distro = \"focal\",\n  FROM = \"rocker/verse\"\n)\nmy_dock\n```\n\n## Contact\n\nQuestions and feedbacks [welcome](mailto:contact@colinfay.me)!\n\nYou want to contribute ? Open a [PR](https://github.com/ThinkR-open/dockerfiler/pulls) :) If you encounter a bug or want to suggest an enhancement, please [open an issue](https://github.com/ThinkR-open/dockerfiler/issues).\n\nPlease note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md).\nBy participating in this project you agree to abide by its terms.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FThinkR-open%2Fdockerfiler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FThinkR-open%2Fdockerfiler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FThinkR-open%2Fdockerfiler/lists"}