Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

packrat::restore() fails for Github package in Dockerfile #574

Open
gacolitti opened this issue Aug 28, 2019 · 3 comments
Open

packrat::restore() fails for Github package in Dockerfile #574

gacolitti opened this issue Aug 28, 2019 · 3 comments

Comments

@gacolitti
Copy link

This line runs fine inside the Dockerfile:

devtools::install_github('nik01010/dashboardthemes', lib = '/root/shiny-planting-schedule/packrat/lib')

But if I try to packrat::restore() inside the Dockerfile I get an error when installing the above package from Github:

packrat::restore(project = '/root/shiny-planting-schedule')

Error:

Installing scales (1.0.0) ...
        OK (built source)
Installing dashboardthemes (1.0.5) ...
FAILED
Error in getSourceForPkgRecord(pkgRecord, srcDir(project), availablePackagesSource(repos = repos),  :
  Failed to download package from URL:
- 'https://api.github.com/repos/nik01010/dashboardthemes/tarball/91524951f8ac635c46711b7693bd468751ffb995'
Calls: <Anonymous> ... restoreImpl -> playActions -> installPkg -> getSourceForPkgRecord
Execution halted
The command '/bin/sh -c R -e "packrat::restore(project = '/root/shiny-planting-schedule')"' returned a non-zero code: 1

Here is the full Dockerfile:

# Install R version 3.6.1 with rstudio, tidyverse, and tex/publishing related packages
FROM rocker/verse:3.6.1

# Install Ubuntu packages
RUN apt-get update && apt-get install -y \
  sudo \
  gdebi-core \
  pandoc \
  pandoc-citeproc \
  libcurl4-gnutls-dev \
  libxml2-dev \
  libudunits2-dev \
  libcairo2-dev \
  libgdal-dev \
  libgeos-dev \
  libproj-dev \
  libxt-dev \
  libssl-dev

RUN mkdir /root/shiny-planting-schedule
RUN mkdir /root/shiny-planting-schedule/app
RUN mkdir /root/shiny-planting-schedule/packrat
RUN mkdir /root/shiny-planting-schedule/packrat/lib

COPY packrat /root/shiny-planting-schedule/packrat

RUN install2.r devtools \
  && rm -rf /tmp/downloaded_packages/ /tmp/*.rds

RUN R -e "devtools::install_github('rstudio/packrat')"

COPY packrat /root/shiny-planting-schedule/packrat

# Restore project packages with packrat
RUN R -e "packrat::restore(project = '/root/shiny-planting-schedule')"

# Copy app folder to image
COPY app /root/shiny-planting-schedule/app

# Make the ShinyApp available at port
EXPOSE 3838

CMD ["R", "-e", "setwd('root/shiny-planting-schedule'); source('/root/shiny-planting-schedule/app/source-file.R')"]
@kevinushey
Copy link
Contributor

Does installing curl in your Dockerfile help?

@gacolitti
Copy link
Author

No, installing curl didn't seem to help. It still gets hung up on dashboardthemes.

@gacolitti
Copy link
Author

If I use R 3.5.3 to install packages, packrat::snapshot(), and finally use rocker/verse:3.5.3 inside the Dockerfile, packrat::restore() during build no longer fails when installing dashboardthemes.

Here is the Dockerfile that works:

FROM rocker/verse:3.5.3

# Install Ubuntu packages
RUN apt-get update && apt-get install -y \
  sudo \
  gdebi-core \
  pandoc \
  pandoc-citeproc \
  libcurl4-gnutls-dev \
  libxml2-dev \
  libudunits2-dev \
  libcairo2-dev \
  libgdal-dev \
  libgeos-dev \
  libproj-dev \
  libxt-dev \
  libssl-dev \
  curl

RUN mkdir /root/shiny-planting-schedule
RUN mkdir /root/shiny-planting-schedule/app
RUN mkdir /root/shiny-planting-schedule/packrat

# copy packrat lock file with package version information
COPY packrat /root/shiny-planting-schedule/packrat

# Install packrat
RUN install2.r packrat \
  && rm -rf /tmp/downloaded_packages/ /tmp/*.rds

# Copy packrat folder
COPY packrat /root/shiny-planting-schedule/packrat

# Restore project packages with packrat
RUN R -e "packrat::restore(project = '/root/shiny-planting-schedule')"

# Copy app folder to image
COPY app /root/shiny-planting-schedule/app

# Make the ShinyApp available at port
EXPOSE 3838

CMD ["R", "-e", "setwd('root/shiny-planting-schedule'); source('/root/shiny-planting-schedule/app/source-file.R')"]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants