0

I have created the following dockerfile to deploy an application

# get shiny serves plus tidyverse packages image
FROM rocker/r-ver:latest

RUN apt-get update && apt-get install -y \
sudo \
pandoc \
pandoc-citeproc \
libcurl4-gnutls-dev \
libcairo2-dev \
libxt-dev \
libssl-dev \
libxml2-dev \
libssh2-1-dev 

 RUN R -e "install.packages('devtools')"

 RUN R -e "require(devtools)"

RUN R -e 'install_version("WeibullR", version = "1.1.10", repos="http://cran.us.r- 
project.org")'

The build fails. I request someone to guide me. I am unable to get it to work

r2evans
  • 141,215
  • 6
  • 77
  • 149
Raghavan vmvs
  • 1,213
  • 1
  • 10
  • 29
  • 1
    FYI, you should almost always use `library`, not `require`. The latter never stops following code when the package is not available, which is almost never what is intended. Refs: https://stackoverflow.com/a/51263513. Further, since `require(.)` and `library(.)` are for the current instance of R, since you are running each of these in separate R processes, the `require(devtools)` (whether true or false) will have no impact on the third execution of R. I suggest you remove the "require" and change the last to be `RUN R 'devtools::install_version(...)'`. – r2evans Aug 02 '22 at 11:24
  • 1
    But ... *"The build fails"*. **How?** Error messages give us a LOT of information. – r2evans Aug 02 '22 at 11:25
  • 1
    Why are you installing the older version of `WeibullR`, rather than the current one? – user2554330 Aug 02 '22 at 11:27
  • Some syntax changes. I need the older version as I have completed my project in it – Raghavan vmvs Aug 02 '22 at 14:36
  • @r2evans function install_version is not found is one error I get. The code refuses to progress any further – Raghavan vmvs Aug 02 '22 at 14:40
  • 1
    I wondered if that's the case. Again, please post the literal errors you get from this. I suspect that your first `install.packages("devtools")` is either returning an error, or it is installing into a location that does not persist between calls. As an alternative, try a single run, something like `RUN R -e 'install.packages("remotes"); remotes::install_version"WeibullR", version = "1.1.10", repos="http://cran.us.r-project.org")'`. – r2evans Aug 02 '22 at 14:56
  • 1
    Done sir. Will give this a try – Raghavan vmvs Aug 02 '22 at 15:12
  • 1
    @r2evans have used your suggestion. many thanks. it helped immensely and I was able to post a solution as well. – Raghavan vmvs Aug 04 '22 at 11:06

1 Answers1

0

I have found a solution that works. Am posting the same so that someone could consider it a solution

get shiny server plus tidyverse packages image
FROM rocker/r-ver:latest
FROM rocker/shiny-verse:latest

RUN apt-get update && apt-get install -y \
sudo \
pandoc \
pandoc-citeproc \
libcurl4-gnutls-dev \
libcairo2-dev \
libxt-dev \
libssl-dev \
libxml2-dev \
libssh2-1-dev 

RUN R -e "install.packages('devtools')"

RUN R -e "require(devtools)"

RUN R -e 'install_version("WeibullR", version = "1.1.10", 
repos="http://cran.us.r- 
project.org")'

This works neatly.

Raghavan vmvs
  • 1,213
  • 1
  • 10
  • 29
  • 1
    It seems that the only difference is the second `FROM` using the shiny-verse package. My guess is that _that_ image contains (and loads?) `devtools`, so your first two `RUN` statements should be unnecessary. I'm glad you were able to find a solution. – r2evans Aug 04 '22 at 12:32