Skip to content

Commit

Permalink
Merge pull request #128 from nuest/master
Browse files Browse the repository at this point in the history
Use stevedore
  • Loading branch information
nuest authored Aug 15, 2018
2 parents d0ca269 + c96e3a5 commit 51d7b26
Show file tree
Hide file tree
Showing 131 changed files with 1,691 additions and 1,381 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
.Rhistory
.Rapp.history
# Session Data files
.RData
.Rdata
# Example code in package build process
*-Ex.R
# Output files from R CMD build
Expand Down Expand Up @@ -32,8 +32,6 @@ tests/testthat/package_markdown/units/*\.html

tests/testthat/Rplots\.pdf

tests/testthat/package_markdown/spacetime/main\.html

vignettes/sessionInfo\.Rdata

sessionInfo\.Rdata
45 changes: 2 additions & 43 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# For a potential alternative configuration see https://github.com/metacran/r-builder

language: r
services:
- docker

r:
- release
Expand All @@ -28,48 +30,5 @@ before_install:
# activate liblwgeom by:
- sudo ldconfig
- Rscript -e 'update.packages(ask = FALSE)' # https://github.com/travis-ci/travis-ci/issues/6850
- Rscript -e 'install.packages("devtools"); devtools::install_deps(dependencies = TRUE)'
#- Rscript -e 'devtools::install_dev_deps()'

warnings_are_errors: true

services:
- docker

r_packages:
- rgdal
- roxygen2
- covr
#- lintr
- testthat
- codetools
- sp
- gstat
- proj4
- devtools
- units
- sf
- fortunes
- lwgeom
# needed for rendering spacetime/main.Rmd
- plm
- spacetime
- mapdata
- lattice
- RColorBrewer
- xts
- maptools
- maps
- diveMove
- trip
- adehabitatLT
- cshapes

after_failure:
- Rscript -e 'library(methods)' -e 'devtools::test()'

#after_success:
# - Rscript -e 'covr::codecov()'
# - Rscript -e 'lintr::lint_package()'
# - echo $TRAVIS_R_VERSION
# - echo $TRAVIS_OS_NAME
13 changes: 7 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: containerit
Type: Package
Title: Package R in Docker Containers
Version: 0.4.0
Version: 0.5.0.9000
Authors@R: c(person("Daniel", "Nuest", role = c("aut", "cre"), email = "[email protected]", comment = c(ORCID = "0000-0003-2392-6140")),
person("Matthias", "Hinz", role = c("aut"), email = "[email protected]", comment = c(ORCID = "0000-0001-6837-9406")))
Author: Daniel Nuest [aut, cre], Matthias Hinz [aut]
Expand All @@ -19,11 +19,13 @@ Imports:
devtools,
semver,
automagic,
sessioninfo
sessioninfo,
stevedore,
versions
VignetteBuilder: knitr
Description: Package R sessions, scripts, workspaces and vignettes together with
all dependencies to execute them in Docker containers. This package is supported
by the project Opening Reproducible Research (http://o2r.info).
by the project Opening Reproducible Research (https://o2r.info).
License: GPL-3 + file LICENSE
URL: https://github.com/o2r/containerit/
BugReports: https://github.com/o2r/containerit/issues
Expand All @@ -38,7 +40,6 @@ Suggests:
rgdal,
maptools,
magrittr,
harbor,
lintr,
sp,
gstat,
Expand All @@ -49,7 +50,7 @@ Suggests:
fortunes,
remotes,
ggplot2
RoxygenNote: 6.0.1
RoxygenNote: 6.1.0
Collate:
'Class-Instruction.R'
'Class-Add.R'
Expand Down Expand Up @@ -83,4 +84,4 @@ Collate:
'sessionInfo-localbuild-methods.R'
'utility-functions.R'
Remotes: github::r-hub/sysreqs,
github::wch/harbor
github::richfitz/stevedore
5 changes: 2 additions & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export(Workdir)
export(clean_session)
export(containerit_write_config)
export(docker_build)
export(docker_inspect)
export(dockerfile)
export(getGitHubRef)
export(getImageForVersion)
Expand Down Expand Up @@ -64,10 +63,10 @@ exportMethods(print)
exportMethods(toString)
exportMethods(write)
import(futile.logger)
importFrom(harbor,docker_cmd)
importFrom(harbor,localhost)
importFrom(methods,"slot<-")
importFrom(methods,new)
importFrom(methods,slot)
importFrom(semver,parse_version)
importFrom(stevedore,docker_available)
importFrom(stevedore,docker_client)
importFrom(utils,sessionInfo)
2 changes: 1 addition & 1 deletion R/Class-Add.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2017 Opening Reproducible Research (http://o2r.info)
# Copyright 2018 Opening Reproducible Research (https://o2r.info)

#' Add-instruction class yet to be implemented
#' @include Class-Instruction.R
Expand Down
2 changes: 1 addition & 1 deletion R/Class-All.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2017 Opening Reproducible Research (http://o2r.info)
# Copyright 2018 Opening Reproducible Research (https://o2r.info)

#' Class union for slots taking either numeric or character input
#'
Expand Down
2 changes: 1 addition & 1 deletion R/Class-Arg.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2017 Opening Reproducible Research (http://o2r.info)
# Copyright 2018 Opening Reproducible Research (https://o2r.info)

#' Arg-instruction class yet to be implemented
#' @include Class-Instruction.R
Expand Down
2 changes: 1 addition & 1 deletion R/Class-Cmd.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2017 Opening Reproducible Research (http://o2r.info)
# Copyright 2018 Opening Reproducible Research (https://o2r.info)

#' An S4 class to represent a CMD instruction
#' @include Class-Instruction.R
Expand Down
8 changes: 4 additions & 4 deletions R/Class-Comment.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2017 Opening Reproducible Research (http://o2r.info)
# Copyright 2018 Opening Reproducible Research (https://o2r.info)

#' Instructionclass representing a comment
#'
Expand All @@ -25,9 +25,9 @@ setClass("Comment",
#' @examples
#' # A simple label that occupies one line:
#' comment <- Comment(text = "this is important to note")
#' df <- dockerfile(clean_session())
#' addInstruction(df) <- comment
#' print(df)
#' the_dockerfile <- dockerfile(clean_session())
#' addInstruction(the_dockerfile) <- comment
#' print(the_dockerfile)
#'
Comment <- function(text) {
methods::new("Comment", text = text)
Expand Down
2 changes: 1 addition & 1 deletion R/Class-Copy.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2017 Opening Reproducible Research (http://o2r.info)
# Copyright 2018 Opening Reproducible Research (https://o2r.info)

#' S4 Class representing a COPY-instruction
#'
Expand Down
2 changes: 1 addition & 1 deletion R/Class-Dockerfile.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2017 Opening Reproducible Research (http://o2r.info)
# Copyright 2018 Opening Reproducible Research (https://o2r.info)

#' An S4 class to represent a Dockerfile
#'
Expand Down
2 changes: 1 addition & 1 deletion R/Class-Entrypoint.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2017 Opening Reproducible Research (http://o2r.info)
# Copyright 2018 Opening Reproducible Research (https://o2r.info)

#' Entrypoint class yet to be implemented
#' @include Class-Instruction.R
Expand Down
2 changes: 1 addition & 1 deletion R/Class-Env.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2017 Opening Reproducible Research (http://o2r.info)
# Copyright 2018 Opening Reproducible Research (https://o2r.info)

#' Env class yet to be implemented
#' @include Class-Instruction.R
Expand Down
2 changes: 1 addition & 1 deletion R/Class-Expose.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2017 Opening Reproducible Research (http://o2r.info)
# Copyright 2018 Opening Reproducible Research (https://o2r.info)

#' S4 Class representing an EXPOSE-instruction
#'
Expand Down
2 changes: 1 addition & 1 deletion R/Class-From.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2017 Opening Reproducible Research (http://o2r.info)
# Copyright 2018 Opening Reproducible Research (https://o2r.info)

setClass("Tag", contains = "character")
setClass("Digest", contains = "character")
Expand Down
2 changes: 1 addition & 1 deletion R/Class-Healthcheck.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2017 Opening Reproducible Research (http://o2r.info)
# Copyright 2018 Opening Reproducible Research (https://o2r.info)

#' Healthcheck-instruction class yet to be implemented
#' @include Class-Instruction.R
Expand Down
2 changes: 1 addition & 1 deletion R/Class-Instruction.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2017 Opening Reproducible Research (http://o2r.info)
# Copyright 2018 Opening Reproducible Research (https://o2r.info)

#' The Docker Instruction - Class
#'
Expand Down
12 changes: 6 additions & 6 deletions R/Class-Label.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2017 Opening Reproducible Research (http://o2r.info)
# Copyright 2018 Opening Reproducible Research (https://o2r.info)

#' Instruction class representing a LABEL
#'
Expand Down Expand Up @@ -39,9 +39,9 @@ setClass("Label",
#' )
#' #label with fixed namespace for all keys
#' label3 <- Label("name"="A name", "description" = "A description", label_ns = "my.label.ns.")
#' df <- dockerfile(clean_session())
#' addInstruction(df) <- list(label1, label2, label3)
#' cat(format(df),sep = "\n")
#' the_dockerfile <- dockerfile(clean_session())
#' addInstruction(the_dockerfile) <- list(label1, label2, label3)
#' cat(format(the_dockerfile),sep = "\n")
#'
Label <-
function(...,
Expand All @@ -67,8 +67,8 @@ Label <-
#'
#' @examples
#' session <- clean_session()
#' df <- dockerfile(session)
#' addInstruction(df) <- Label_SessionInfo(session)
#' the_dockerfile <- dockerfile(session)
#' addInstruction(the_dockerfile) <- Label_SessionInfo(session)
Label_SessionInfo <-
function(session = sessionInfo(),
as_json = FALSE) {
Expand Down
2 changes: 1 addition & 1 deletion R/Class-Maintainer.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2017 Opening Reproducible Research (http://o2r.info)
# Copyright 2018 Opening Reproducible Research (https://o2r.info)

#' An S4 class to represent a Dockerfile's maintainer
#' @include Class-Instruction.R
Expand Down
2 changes: 1 addition & 1 deletion R/Class-Onbuild.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2017 Opening Reproducible Research (http://o2r.info)
# Copyright 2018 Opening Reproducible Research (https://o2r.info)

#' Onbuild-instruction class yet to be implemented
#' @include Class-Instruction.R
Expand Down
4 changes: 2 additions & 2 deletions R/Class-Run.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2017 Opening Reproducible Research (http://o2r.info)
# Copyright 2018 Opening Reproducible Research (https://o2r.info)

#' An S4 class to represent a RUN instruction in shell form
#' @include Class-Instruction.R
Expand Down Expand Up @@ -79,7 +79,7 @@ setClass("Run",
#' Create objects representing a RUN instruction
#'
#' @param exec character argument naming the executable
#' @param params parameter arguments
#' @param params parameter arguments, of class character
#' @family Run instruction
#' @return An S4 object of class Run
#' @export
Expand Down
2 changes: 1 addition & 1 deletion R/Class-Shell.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2017 Opening Reproducible Research (http://o2r.info)
# Copyright 2018 Opening Reproducible Research (https://o2r.info)

#' Shell-instruction class yet to be implemented
#' @include Class-Instruction.R
Expand Down
2 changes: 1 addition & 1 deletion R/Class-Stopsignal.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2017 Opening Reproducible Research (http://o2r.info)
# Copyright 2018 Opening Reproducible Research (https://o2r.info)

#' Stopsignal-instruction class yet to be implemented
#' @include Class-Instruction.R
Expand Down
2 changes: 1 addition & 1 deletion R/Class-Volume.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2017 Opening Reproducible Research (http://o2r.info)
# Copyright 2018 Opening Reproducible Research (https://o2r.info)

#' Volume class yet to be implemented
#' @include Class-Instruction.R
Expand Down
2 changes: 1 addition & 1 deletion R/Class-Workdir.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2017 Opening Reproducible Research (http://o2r.info)
# Copyright 2018 Opening Reproducible Research (https://o2r.info)

#' S4 Class representing a WORKDIR instruction
#' @include Class-Instruction.R
Expand Down
8 changes: 4 additions & 4 deletions R/LabelSchemaFactory.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2017 Opening Reproducible Research (http://o2r.info)
# Copyright 2018 Opening Reproducible Research (https://o2r.info)

#' Create Build-time labels according to Label Schema Convention
#'
Expand All @@ -19,14 +19,14 @@
#' @family label
#'
#' @examples
#' df <- dockerfile(clean_session())
#' the_dockerfile <- dockerfile(clean_session())
#' factory <- LabelSchemaFactory()
#' label <- factory(name = "ImageName",
#' description = "Description of the image",
#' build_date = Sys.time()
#' )
#' addInstruction(df) <- label
#' cat(format(df))
#' addInstruction(the_dockerfile) <- label
#' cat(format(the_dockerfile))
#'
#'
LabelSchemaFactory <- function() {
Expand Down
24 changes: 15 additions & 9 deletions R/baseimages.R
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
# Copyright 2017 Opening Reproducible Research (http://o2r.info)
# Copyright 2018 Opening Reproducible Research (https://o2r.info)

#' Detect packages in a Docker image
#'
#' Extracts all installed packages from a Docker image by running it.
#' The method is based on \code{harbor::docker_cmd}.
#' The method is based on \code{stevedore}.
#'
#' @param host A host object (see harbor-package)
#' @param image Name of the new image to be run
#'
#' @return A \code{data.frame} with installed packages and their version of the image
#' @export
#@importFrom harbor localhost docker_cmd
get_installed_packages <- function(host = harbor::localhost, image) {
args = c("--rm", image, "Rscript", "-e", "write.csv(as.data.frame(installed.packages())[,c(\"Version\")])")
futile.logger::flog.info("EXEC: docker run %s", paste(args, collapse = " "))
#' @importFrom stevedore docker_client docker_available
get_installed_packages <- function(image) {
stopifnot(stevedore::docker_available())

output <- harbor::docker_cmd(host = harbor::localhost, cmd = "run", args = args, capture_text = TRUE)
pkgs <- read.csv(text = output)
cmd = c("Rscript", "-e", "write.csv(x = as.data.frame(installed.packages())[,c(\"Version\")])")
futile.logger::flog.info("Running command %s in %s", paste(cmd, collapse = " "), image)

.client <- stevedore::docker_client()
.container <- .client$container$run(image = image,
cmd = cmd,
rm = TRUE,
name = "containerit_get_installed_packages")

pkgs <- read.csv(text = .container$logs)
names(pkgs) <- c("pkg", "version")
attributes(pkgs)$image <- image
return(pkgs)
Expand Down
2 changes: 1 addition & 1 deletion R/containerit-config.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2017 Opening Reproducible Research (http://o2r.info)
# Copyright 2018 Opening Reproducible Research (https://o2r.info)

# You can use the following code to manually inspect and manipulate the configuration file.
if (FALSE) {
Expand Down
2 changes: 1 addition & 1 deletion R/containerit.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2017 Opening Reproducible Research (http://o2r.info)
# Copyright 2018 Opening Reproducible Research (https://o2r.info)

#' containerit: A package for packaging R objects and their dependencies in software containers
#'
Expand Down
2 changes: 1 addition & 1 deletion R/defaults.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2017 Opening Reproducible Research (http://o2r.info)
# Copyright 2018 Opening Reproducible Research (https://o2r.info)

.rocker_images <- c(
versioned = "rocker/r-ver",
Expand Down
Loading

0 comments on commit 51d7b26

Please sign in to comment.