• Stars
    star
    289
  • Rank 143,419 (Top 3 %)
  • Language
    R
  • License
    GNU General Publi...
  • Created over 8 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Package an R workspace and all dependencies as a Docker container

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

<script type='text/javascript' src='https://d1bxh8uas1mnw7.cloudfront.net/assets/embed.js'></script>

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

  • containerit only fully works if you have Docker installed and is only tested with Docker Engine - Community (previously called Docker Community Edition or Docker CE).
  • R (>= 3.5.0) is needed so that some dependencies (e.g. BiocManager) are available; older versions of R predate the development of the package and were never tested.

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.

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.

Install

Installation is only possible from GitHub:

# 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())
#> INFO [2021-06-25 11:10:38] Created Dockerfile-Object based on sessionInfo
print(my_dockerfile)
#> FROM rocker/r-ver:4.1.0
#> LABEL maintainer="daniel"
#> WORKDIR /payload/
#> CMD ["R"]

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.

rmd_dockerfile <- containerit::dockerfile(from = "inst/demo.Rmd",
                                          image = "rocker/verse:3.5.2",
                                          maintainer = "o2r",
                                          filter_baseimage_pkgs = TRUE)
#> Detected API version '1.41' is above max version '1.39'; downgrading
#> Detected API version '1.41' is above max version '1.39'; downgrading
print(rmd_dockerfile)
#> FROM rocker/verse:3.5.2
#> LABEL maintainer="o2r"
#> # CRAN packages skipped because they are in the base image: knitr
#> RUN ["install2.r", "fortunes"]
#> WORKDIR /payload/
#> CMD ["R"]

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

Images

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

The Dockerfiles are available in the directory inst/docker/Dockerfile.

verse

docker inspect o2rproject/containerit

Base image: rocker/verse:4.0.5

geospatial

docker inspect o2rproject/containerit:geospatial

Base image: rocker/geospatial:4.0.5

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.

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 to avoid some mistakes.

A codemeta file, codemeta.json, with metadata about the package and its dependencies is generated automatically when this document is compiled.

codemetar::write_codemeta(".")
#> Added codemeta.json to .Rbuildignore
#> codemetar has the highest opinion of this R package :-)

Citation

To cite containerit in publications use:

  Nüst, D. and Hinz, M. (2019). containerit: Generating Dockerfiles for
  reproducible research with R. Journal of Open Source Software, 4(40),
  1603, https://doi.org/10.21105/joss.01603

A BibTeX entry for LaTeX users is

  @Article{,
    title = {{containerit: Generating Dockerfiles for reproducible research with R}},
    author = {Daniel Nüst and Matthias Hinz},
    journal = {{Journal of Open Source Software}},
    year = {2019},
    month = {8},
    volume = {4},
    number = {40},
    pages = {1603},
    doi = {10.21105/joss.01603},
    url = {https://doi.org/10.21105/joss.01603},
  }

License

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

Copyright (C) 2019 - o2r project.

More Repositories

1

architecture

Architecture and overarching documentation for o2r microservices
Makefile
10
star
2

erc-spec

Executable Research Compendium specification and guides
7
star
3

ctv-computational-environments

A CRAN task view for computational environments and reproducibility
HTML
6
star
4

reference-implementation

A catch-all repository to run all o2r microservices and the user interface platform
Makefile
4
star
5

o2r-badger

API for serving badges on reproducibility of research.
JavaScript
4
star
6

o2r-project.github.io

Website of the research project "Opening Reproducible Research"
JavaScript
3
star
7

o2r-inspecter

Inspection of compendium details as part of the o2r Web API
R
3
star
8

o2r-UI

User interface for creating and examining Executable Research Compendia (ERC)
HTML
3
star
9

api

Reproducibility service RESTful web API specification and documentation
Makefile
3
star
10

o2r-muncher

Node.js implementation of the ERC execution and job control part of the o2r web API
HTML
2
star
11

o2r-bagtainers

R
2
star
12

o2r-platform

⚠️ Project discontinued ⚠️ See https://github.com/o2r-project/o2r-UI
JavaScript
2
star
13

o2r-meta

Metadata toolsuite for an extract-map-validate workflow supporting reproducible research
HTML
2
star
14

o2r-bindings

Linking data, text, and code to make research results transparent and better accessible.
HTML
2
star
15

o2r-finder

Node.js implementation of search features for the o2r API
JavaScript
1
star
16

o2r-bouncer

Node.js implementation for the oauth2-authentification process of the o2r web api
JavaScript
1
star
17

erc-examples

Examples for Executable Research Compendia and compatible workspaces
HTML
1
star
18

o2r-paperfinder

A script for automatically downloading and scanning PDFs which include code in R or Python
JavaScript
1
star
19

ansible

Ansible configuration to deploy o2r reference implementation
Jinja
1
star
20

geoextent

Python library for extrating geospatial extent of files and directories with multiple data formats
Jupyter Notebook
1
star
21

o2r-substituter

Create a new compendium based on existing compendia
HTML
1
star
22

o2r-extender

Allows the integration of badges into several research websites and data repositories.
JavaScript
1
star