Search code examples
rdockershinyleafletr-leaflet

Error in library(leaflet) : there is no package called ‘leaflet’


I wrote the docker file like this to deploy the shiny r application

FROM rocker/r-base:latest\
RUN apt-get update && apt-get install -y --no-install-recommends \
    sudo \
    libcurl4-gnutls-dev \
    libcairo2-dev \
    libxt-dev \
    libssl-dev \
    libssh2-1-dev \
    && rm -rf /var/lib/apt/lists/*

RUN install.r shiny
RUN install.r shinydashboard


RUN R -e "install.packages(c('ggmap','ggplot2','leaflet'),dependencies = TRUE, repos='http://cran.rstudio.com/')"


RUN echo "local(options(shiny.port = 3838, shiny.host = '0.0.0.0'))" > /usr/lib/R/etc/Rprofile.site

RUN addgroup --system app \
    && adduser --system --ingroup app app

WORKDIR /home/app

COPY app .

RUN chown app:app -R /home/app

USER app

EXPOSE 3838

CMD ["R", "-e", "shiny::runApp('/home/app')"]

next, I build a docker file

docker build -t test-shiny .

after run the build docker image

docker run -p 3838:3838 test-shiny

this time I got an error like this

error message

my app Global.R file like this library(shiny) library(shinydashboard) library(shinyMobile) library(ggmap) library(ggplot2) library(leaflet)

what I can do fix leaflet package issue, someone can help me!


Solution

  • I got a solution for that

    RUN
    sudo \
    libgdal-dev \
    libproj-dev \
    libgeos-dev \
    libudunits2-dev \
    netcdf-bin \
    

    Install these dependencies