UNPKG

5.55 kBMarkdownView Raw
1## Using Dockter
2
3This document will take you through using Dockter to make your work reproducible and easy to reuse.
4
5#### Prerequisites
6
7You should have some basic working knowledge of Docker. [This hands-on tutorial](https://ome.github.io/training-docker/) is a good way to start. You can also
8check out the [Katakoda set of Docker courses](https://www.katacoda.com/courses/docker).
9
10#### Motivation
11
12We encourage you to have a look at the above courses but the idea behind Dockter is that you don't need to master Docker. Dockter does most of the things for you
13in order to set up a reproducible research environment.
14
15Dockter is a tool to make it easier for researchers to create reproducible research environments. It generates a Docker image for a research project based on the source code in it. That means that you don’t need to learn a new file format (`Dockerfiles`) to create Docker images. Dockter makes it also easy to track dependencies and update the image when they change.
16
17In addition, Dockter manages the image building process to better fit your everyday workflow (determines package system dependencies, manages builds) and generates JSON-LD meta-data describing the image (from which citations etc can be generated).
18
19You can manually edit the files which Dockter generates so that the containers build of it exactly suit your project.
20
21#### 1. Install
22
23a) Download the latest stable binary package (ready to run) [for your operating system](https://github.com/stencila/dockter/releases):
24
25b) Copy the binary file into the folder where you would like Dockter to be (eg. `Applications` on your Mac OS, or `Program Files` on Windows).
26
27c) Once the file is downloaded, rename it to `dockter` Dockter is a command line tool (at least for now) so you need to interact with it through the terminal (on Windows it will be Power Shell).
28
29**Basic use**
30
31```
32 dockter compile [folder] [format] Compile a project to a software environment
33 dockter build [folder] Build a Docker image for project
34 dockter execute [folder] [format] Execute a project
35```
36
37
38#### 2. Dockter for R
39
40Dockter can create a software environment file which reflects the requirements to run the project written in R.
41The software environment file is a file in `JSON` or `yaml` format with comprehensive meta data about the project.
42Dockter parses the folder with the R project for `R` and `Rmd` files and extracts the relevant information.
43
44 * For each R package installed or loaded, the meta data is retrieved from [CRAN](http://crandb.r-pkg.org).
45 * System dependencies for each package are obtained from [R-Hub](https://sysreqs.r-hub.io/pkg/xml2).
46 * Meta data about the authors, title, abstract and so on.
47
48Try out Dockter on the `example.R` file included in this folder.
49
50```
51dockter compile dockter/doc
52```
53
54You will see the output on your screen in `JSON` and two files: `.Dockerfile` and `.DESCRIPTION` generated in the project folder:
55
56`.Dockerfile` will look more or less like the one below:
57
58```
59# Generated by Dockter 2018-10-23T09:17:23.748Z
60# To stop Dockter generating this file and start editing it yourself, rename it to "Dockerfile".
61
62FROM ubuntu:16.04
63
64ENV TZ="Etc/UTC"
65
66RUN apt-get update \
67 && DEBIAN_FRONTEND=noninteractive apt-get install -y \
68 apt-transport-https \
69 ca-certificates \
70 software-properties-common
71
72RUN apt-add-repository "deb https://mran.microsoft.com/snapshot/2018-10-22/bin/linux/ubuntu xenial/" \
73 && apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 51716619E084DAB9
74
75RUN apt-get update \
76 && DEBIAN_FRONTEND=noninteractive apt-get install -y \
77 r-base \
78 && apt-get autoremove -y \
79 && apt-get clean \
80 && rm -rf /var/lib/apt/lists/*
81
82# dockter
83
84COPY .DESCRIPTION DESCRIPTION
85RUN bash -c "Rscript <(curl -sL https://unpkg.com/@stencila/dockter/src/install.R)"
86
87COPY environment-example.R environment-example.R
88COPY example.R example.R
89
90CMD Rscript environment-example.R
91```
92#### 3. Dockter for Python
93
94Dockter can create a software environment file which reflects the requirements to run the project written in Python.
95The software environment file is a file in `JSON` or `yaml` format with comprehensive meta data about the project.
96Dockter parses the folder with the Python project for `py` files and extracts the relevant information.
97
98#### 4. Real-life example
99
100To demonstrate convenience of using Dockter, try running it for one of the [Software Carpentry modules](https://github.com/swcarpentry/r-novice-inflammation)
101for learning R. The repository with the module contains a range of source code files, including 'python`, `JS`, `Rmd` and `R`.
102First, clone the repository on your machine:
103
104```
105git clone https://github.com/swcarpentry/r-novice-inflammation.git
106```
107
108Run `dockter compile` on the whole directory:
109
110```
111dockter compile r-novice-inflammation
112```
113
114Then, `dockter build` to create a `Docker` image so that the module can be run (note, `dockter` will likely have to download and install a number
115of packages, this may take a while):
116
117```
118dockter build r-novice-inflammation
119```
120
121Check if the image is there:
122
123```
124docker images
125```
126
127And you should see the image on the list:
128
129``` TAG IMAGE ID CREATED SIZE
130rnoviceinflammation latest 149d3dc3fc73 20 minutes ago 1.12GB
131```
132
133### Resources
134
135[A beginner's guide to containters](https://medium.freecodecamp.org/a-beginner-friendly-introduction-to-containers-vms-and-docker-79a9e3e119b)
136
137