benmarwick / testcontainerit

Other
1 stars 1 forks source link

How to copy all compendium files into this container? #2

Open benmarwick opened 4 years ago

benmarwick commented 4 years ago

The copy argument in containerit::dockerfile() does not seem to work as expected. I never get any files in my container. How can I get all the files in my compendium into the container using containerit::dockerfile()?

https://github.com/benmarwick/testcontainerit/blob/master/devhistory.R#L29

Currently I'm doing this to COPY files into the container, how can I do this with containerit::dockerfile() ? Can we get the COPY argument fully exposed in the R function?


# get the base image, the rocker/verse has R, RStudio and pandoc
FROM rocker/geospatial:3.6.1

# required
MAINTAINER Your Name <your_email@somewhere.com>

COPY . /compendium

# go into the repo directory
RUN . /etc/environment \
  # Install linux depedendencies here
  # e.g. need this for ggforce::geom_sina
  && sudo apt-get update \
  && sudo apt-get install libudunits2-dev -y \
  # build this compendium package
  && R -e "devtools::install_github('trinker/pacman'); devtools::install('/compendium', dep=TRUE)" \
  # render the manuscript into a docx, you'll need to edit this if you've
  # customised the location and name of your main Rmd file
  && R -e "devtools::check('/compendium',error_on = 'error')" \
 && R -e "rmarkdown::render('/compendium/analysis/paper.Rmd')"
nuest commented 4 years ago

When starting with a description object or file, copy simply was not implemented yet because it started out as an option for file-based image generation. What you can do after the commit above is the following:

df_description <- dockerfile(from = here::here("DESCRIPTION"),
                             image = paste0('rocker/verse:',
                                            paste0(R.version$major,".",R.version$minor)),
                             container_workdir = 'compendium/',
                             filter_baseimage_pkgs = TRUE,
                             copy = "." ) # copy all files in the current working directory
> print(df_description)
FROM rocker/verse:3.6.2
LABEL maintainer="daniel"
# CRAN packages skipped because they are in the base image:
RUN ["install2.r", "compendium", "here"]
WORKDIR compendium/
COPY ["./", "./"]
CMD ["R"]

You need development version 0.6.0.9002 for that, currently only in my fork.