https://github.com/smaakage85/dockr
create lightweight docker image for an R package
https://github.com/smaakage85/dockr
docker docker-container docker-image docker-images r
Last synced: 5 months ago
JSON representation
create lightweight docker image for an R package
- Host: GitHub
- URL: https://github.com/smaakage85/dockr
- Owner: smaakage85
- License: other
- Created: 2019-06-03T12:04:24.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-12-15T17:01:01.000Z (over 6 years ago)
- Last Synced: 2024-10-28T03:39:48.691Z (over 1 year ago)
- Topics: docker, docker-container, docker-image, docker-images, r
- Language: HTML
- Size: 428 KB
- Stars: 12
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
README
---
output: github_document
---
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-"
)
```
```{r setup_cran, echo = FALSE}
options(repos = c(CRAN = "https://cran.rstudio.com/"))
```
# dockr
[](https://travis-ci.org/smaakage85/dockr)
[](https://CRAN.R-project.org/package=dockr) [](https://CRAN.R-project.org/package=dockr)
`dockr` is a small toolkit to build a lightweight Docker r-base container
image for your R package, in which the package itself is available. The Docker
image seeks to mirror your R session as close as possible with respect to R
specific dependencies. Both dependencies on CRAN R packages as well as local
non-CRAN R packages will be included in the Docker container image.
## Installation
Install the development version of `dockr` with:
```{r install_github, eval = FALSE}
remotes::install_github("smaakage85/dockr")
```
Or install the version released on CRAN:
```{r install_cran, eval = FALSE}
install.packages("dockr")
```
## Workflow
In order to create the files, that will constitute the Docker image, simply
invoke the `prepare_docker_image()` function and point to the folder with your
package.
The workflow of `prepare_docker_image()` is summarized below:
1. Build and install the package on your system
2. Identify R package dependencies of the package
3. Detect the version numbers of the loaded and installed versions of these
packages on your system
4. Link the individual packages to the right repositories (either CRAN or local repos)
5. Write Dockerfile and create all other files needed to build the Docker r-base image
Now, I will let `dockr` do its magic and create the files for a Docker r-base
container image, in which `dockr` is installed together with all of the R
package dependencies, `dockr` needs to run.
Beware that the files for the Docker image are created as side-effects of the
function call (under the 'dir_image' directory). Also the package is
installed as a side effect (in the 'dir_install' directory).
```{r create_image, warning = FALSE, message = FALSE}
library(dockr)
image_dockr <- prepare_docker_image(".", dir_image = tempdir(),
dir_install = "temp")
```
Great, all necessary files for the Docker image have been created, and you
can build the Docker image right away by following the instructions. It is as
easy as that! Yeah!
## What about non-R dependencies?
`dockr` does _not_ deal with non-R dependencies at this point.
In case that, for instance, your package has any Linux specific dependencies,
you will have to install them yourself in the Docker container image. For that
purpose you can edit the Dockerfile further with the 'write_lines_to_file'
function.
## Contact
I hope, that you will find `dockr` useful.
Please direct any questions and feedbacks to [me](mailto:lars_kjeldgaard@hotmail.com)!
If you want to contribute, open a [PR](https://github.com/smaakage85/dockr/pulls).
If you encounter a bug or want to suggest an enhancement, please [open an issue](https://github.com/smaakage85/dockr/issues).
Best,
smaakagen