knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "README-"
)

containerit containerit logo

DOI Project Status: WIP - Initial development is in progress, but there has not yet been a stable, usable release suitable for the public. Travis CI build status Appveyor build status Join the chat at https://gitter.im/o2r-project/containerit

containerit packages R script/session/workspace and all dependencies as a Docker container by automagically generating a suitable Dockerfile. The package's website is https://o2r.info/containerit/.

Prerequisites

Quick start

Try out containerit in a container

You can spin up a Docker container with containerit pre-installed if you want to try out the package. The default of the containerit images on Docker Hub is to start plain R, but you can also start an with RStudio session in a browser.

Note: The geospatial variant is used so that examples from containerit vignettes are likely to work. For a minimal Dockerfile to run containerit, see inst/docker/minimal/Dockerfile.

```{bash, eval=FALSE} docker run --rm -it -e PASSWORD=o2r -p 8787:8787 o2rproject/containerit:geospatial /init

Now go to http://localhost:8787 and log in with the user `rstudio` and password `o2r`.
Continue in section [Use](#use).

### Install

Installation is only possible from GitHub:

```r
# install.packages("remotes")
remotes::install_github("o2r-project/containerit")

Use

containerit can create Dockerfile objects in R and render them as Dockerfile instructions based on session information objects or runnable R files (.R, .Rmd).

suppressPackageStartupMessages(library("containerit"))
my_dockerfile <- containerit::dockerfile(from = utils::sessionInfo())
print(my_dockerfile)

You can disable logging:

futile.logger::flog.threshold(futile.logger::ERROR)

Now we create a Dockerfile for a specific R version and a given R Markdown file. The option filter_baseimage_pkgs is used to not add any packages already available in the base image, which can save a lot of build time.

```{bash pull, include=FALSE} docker pull rocker/verse:3.6.2

```r
rmd_dockerfile <- containerit::dockerfile(from = "inst/demo.Rmd",
                                          image = "rocker/verse:3.5.2",
                                          maintainer = "o2r",
                                          filter_baseimage_pkgs = TRUE)
print(rmd_dockerfile)

For extended instructions, see the vignettes at in the directory vignettes/, which are readable online at https://o2r.info/containerit/articles/.

Images

dockerfiles_path <- "inst/docker/Dockerfile"
suppressPackageStartupMessages(library("here"))
dockerfile_latest <- readLines(here(dockerfiles_path))
base_image = sub(".*? (.+)", "\\1", dockerfile_latest[[2]])
dockerfile_geospatial <- readLines(here("inst/docker/geospatial/Dockerfile"))
geospatial_base_image = sub(".*? (.+)", "\\1", dockerfile_geospatial[[2]])

Images are available starting from different base images. All images are also available with version tags.

The Dockerfiles are available in the directory `r dockerfiles_path`.

verse

```{bash, eval=FALSE} docker inspect o2rproject/containerit

Base image: `` `r base_image` ``

[![](https://images.microbadger.com/badges/version/o2rproject/containerit.svg)](https://microbadger.com/images/o2rproject/containerit "Get your own version badge on microbadger.com") [![](https://images.microbadger.com/badges/image/o2rproject/containerit.svg)](https://microbadger.com/images/o2rproject/containerit "Get your own image badge on microbadger.com") [![](https://images.microbadger.com/badges/commit/o2rproject/containerit.svg)](https://microbadger.com/images/o2rproject/containerit "Get your own commit badge on microbadger.com")

### geospatial

```{bash eval=FALSE}
docker inspect o2rproject/containerit:geospatial

Base image: `r geospatial_base_image`

RStudio Add-in

RStudio Addins allow to create interactive user interfaces for the RStudio development environment. Courtesy of a great contribution by a group of enthusiasts at the ROpenSci OZ Unconference 2018, there are several forms to quickly create Dockefiles from different use cases, e.g. the current session, a vector of expressions, or a script file.

screenshots containerit RStudio Addin forms

Contribute

All help is welcome: asking questions, providing documentation, testing, or even development.

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

See CONTRIBUTING.md for details.

Development

r-hub builder is great for running checks, e.g. before submitting to CRAN and on other operating systems.

library("rhub")
rhub::check_for_cran()
rhub::check_on_windows()

You can build the pkgdown site with

pkgdown::build_site()

You can build the Docker images locally with the current development version using the following commands.

```{bash dev_containers, eval=FALSE} docker build --tag containerit:dev --file inst/docker/Dockerfile.local . docker build --tag containerit:geospatial-dev --file inst/docker/geospatial/Dockerfile.local .

You can use [`pre-commit` hooks](https://github.com/lorenzwalthert/pre-commit-hooks) to avoid some mistakes.

A [codemeta](https://codemeta.github.io/) file, `codemeta.json`, with metadata about the package and its dependencies is generated automatically when this document is compiled.

```r
codemetar::write_codemeta(".")

Citation

citation("containerit")

License

containerit is licensed under GNU General Public License, version 3, see file LICENSE.

Copyright (C) 2019 - o2r project.



o2r-project/containerit documentation built on June 28, 2021, 2:46 p.m.