I've seen a few other posts about the same issue, but no clear solution from any of them.
When running docker build -t test-shiny ., I get the following error when running the docker image locally:
Error in library(leaflet) : there is no package called ‘leaflet’
Calls: <Anonymous> ... sourceUTF8 -> eval -> eval -> ..stacktraceon.. -> library
Execution halted
Here is my Dockerfile:
# Base image https://hub.docker.com/u/rocker/
FROM rocker/r-base:latest
RUN apt-get update && apt-get -y --no-install-recommends install \
curl \
wget \
sudo \
alien \
redis-server \
gnupg \
unixodbc-dev && \
rm -rf /var/lib/apt/lists/* && \
apt-get clean
RUN apt-get update && apt-get -y --no-install-recommends install \
libpng-dev \
libudunits2-dev \
libgeos-dev \
libproj-dev \
libssl-dev \
libcurl4-openssl-dev \
libhiredis-dev \
libmagick++-dev && \
rm -rf /var/lib/apt/lists/* && \
apt-get clean \
libgdal-dev \
netcdf-bin
# Athena ODBC Drivers
RUN wget https://s3.amazonaws.com/athena-downloads/drivers/ODBC/SimbaAthenaODBC_1.1.9.1001/Linux/simbaathena-1.1.9.1001-1.el7.x86_64.rpm && \
sudo alien -i simbaathena-1.1.9.1001-1.el7.x86_64.rpm && \
rm simbaathena-1.1.9.1001-1.el7.x86_64.rpm
# Dependencies
RUN Rscript -e 'install.packages(c("shiny", "shinydashboard", "ggplot2", "patchwork","dbplyr", "dbplot", "scales", "shinycssloaders", "rJava", "RJDBC", "shinyjs", "shinyBS", "highcharter", "leaflet", "DT", "glue", "DBI", "odbc", "data.table"), dependencies = TRUE, repos="http://cran.rstudio.com/", Ncpus=5)' && rm -rf /tmp/downloaded_packages
# Copy App
RUN mkdir shiny-app
COPY evaluation-app/ /shiny-app
# RShiny Port
EXPOSE 3838
# Run App
CMD ["R", "-e", "shiny::runApp('/shiny-app', host = '0.0.0.0', port = 3838)"]
I know I am installing a lot of r packages, but my app runs fine in RStudio. After reading this post, I already tried adding the solution from the accepted answer, but unsuccessful. Any suggestions or solutions would be much appreciated.
Related
I have a docker image with RStudio installed.
My flexdashboard app has a section to download a flextable
save_path = str_c(image_dir, "IX_overviewp2_", sub('-','_',current_quarter), ".png")
save_as_image(ft,
path = save_path,
zoom = 3 ,
webshot = "webshot2") # save flextable as png
but when I get to the section of the code, I receive the error: "google-chrome" and "chromium-browser" were not found. Try setting the CHROMOTE_CHROME environment variable or adding one of these executables to your PATH. Error in initialize(...) : Invalid path to Chrome
I updated my docker image to include chrome with the last two RUN commands of my dockerfile, but this still does not solve my issue.
Does anyone have any suggestions?
FROM rocker/verse
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends build-essential libpq-dev python3.8 python3-pip python3-setuptools python3-dev
RUN pip3 install --upgrade pip
ADD . ./home/rstudio
ADD requirements.txt .
ADD install_packages.r .
# Miniconda and dependencies
RUN cd /tmp/ && \
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && \
bash Miniconda3-latest-Linux-x86_64.sh -b -p $HOME/miniconda3 && \
/root/miniconda3/condabin/conda install -y python=3.7
ENV PATH=$PATH:/root/miniconda3/bin
#RUN npm install phantomjs-prebuilt --phantomjs_cdnurl=http://cnpmjs.org/downloads
# installing python libraries
RUN pip3 install -r requirements.txt
# installing r libraries
RUN Rscript install_packages.r
RUN if ! [[ "16.04 18.04 20.04 21.04 21.10" == *"$(lsb_release -rs)"* ]]; \
then \
echo "Ubuntu $(lsb_release -rs) is not currently supported."; \
exit; \
fi
RUN sudo su
RUN apt-get update && apt-get install -y gnupg2
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list > /etc/apt/sources.list.d/mssql-release.list
RUN exit
RUN sudo apt-get update
RUN sudo ACCEPT_EULA=Y apt-get install -y msodbcsql17
RUN chmod -R 777 /home/rstudio
# Install Chrome WebDriver
RUN CHROMEDRIVER_VERSION=`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE` && \
mkdir -p /opt/chromedriver-$CHROMEDRIVER_VERSION && \
curl -sS -o /tmp/chromedriver_linux64.zip http://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VERSION/chromedriver_linux64.zip && \
unzip -qq /tmp/chromedriver_linux64.zip -d /opt/chromedriver-$CHROMEDRIVER_VERSION && \
rm /tmp/chromedriver_linux64.zip && \
chmod +x /opt/chromedriver-$CHROMEDRIVER_VERSION/chromedriver && \
ln -fs /opt/chromedriver-$CHROMEDRIVER_VERSION/chromedriver /usr/local/bin/chromedriver
# Install Google Chrome
RUN curl -sS -o - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list && \
apt-get -yqq update && \
apt-get -yqq install google-chrome-stable && \
rm -rf /var/lib/apt/lists/*
Try adding in you dockerfile:
RUN wget https://downloads.vivaldi.com/stable/vivaldi-stable_5.5.2805.35-1_amd64.deb
RUN apt-get update && apt-get install -y ./vivaldi-stable_5.5.2805.35-1_amd64.deb && rm -rf /var/lib/apt/lists/*
RUN echo CHROMOTE_CHROME=/usr/bin/vivaldi >> .Renviron
My Dockerfile contains the exact code as shown in the statworx website to build an image for a Shiny app. Whenever I run the following code however:
# Base image https://hub.docker.com/u/rocker/
FROM rocker/shiny:latest
# system libraries of general use
## install debian packages
RUN apt-get update -qq && apt-get -y --no-install-recommends install
libxml2-dev
libcairo2-dev
libsqlite3-dev
libmariadbd-dev
libpq-dev
libssh2-1-dev
unixodbc-dev
libcurl4-openssl-dev
libssl-dev
## update system libraries
RUN apt-get update &&
apt-get upgrade -y &&
apt-get clean
# copy necessary files
## app folder
COPY /example-app ./app
## renv.lock file
COPY /example-app/renv.lock ./renv.lock
# install renv & restore packages
RUN Rscript -e 'install.packages("renv")'
RUN Rscript -e 'renv::consent(provided = TRUE)'
RUN Rscript -e 'renv::restore()'
# expose port
EXPOSE 3838
# run app on container start
CMD ["R", "-e", "shiny::runApp('/app', host = '0.0.0.0', port = 3838)"]
docker build -t my-shinyapp-image .
I get the following error: failed to solve with frontend dockerfile.v0: failed to create LLB definition: dockerfile parse error line 7: unknown instruction: LIBXML2-DEV
If I remove the LIBXML2-DEV package it gives an error on the next one. Has anyone encountered this problem before?
Following the suggestion of #HubertL, here is the Dockerfile that will work:
# Base image https://hub.docker.com/u/rocker/
FROM rocker/shiny:latest
# system libraries of general use
## install Debian/Ubuntu packages
RUN apt-get update -qq && \
apt-get upgrade -y && \
apt-get -y --no-install-recommends install \
libxml2-dev \
libcairo2-dev \
libsqlite3-dev \
libmariadbd-dev \
libpq-dev \
libssh2-1-dev \
unixodbc-dev \
libcurl4-openssl-dev \
libssl-dev
## update system libraries
RUN apt-get update && \
apt-get upgrade -y && \
apt-get clean
# copy necessary files
## app folder
COPY /example-app ./app
## renv.lock file
COPY /example-app/renv.lock ./renv.lock
# install renv & restore packages
RUN Rscript -e 'install.packages("renv")'
RUN Rscript -e 'renv::consent(provided = TRUE)'
RUN Rscript -e 'renv::restore()'
# expose port
EXPOSE 3838
# run app on container start
CMD ["R", "-e", "shiny::runApp('/app', host = '0.0.0.0', port = 3838)"]
I want to build a singularity container for the text-package in R (which is using reticulate to access python). The singularity container builds, and the text-package is installed, and can run textEmbed("hello") as part of the installation process.
But when I start the singularity container and then run: Rscript -e 'text::textEmbed("hello")'. I get an error reading:
Error: Python shared library not found, Python bindings not loaded.
Use reticulate::install_miniconda() if you'd like to install a Miniconda Python environment.
But I have confirmation that it has been installed and that textEmbed("hello") worked in the end of the installation process. Below are the file I'm using to build the singularity container.
Bootstrap: docker
From: ubuntu:20.04
%environment
export LANG=C.UTF-8 LC_ALL=C.UTF-8
export XDG_RUNTIME_DIR=/tmp/.run_$(uuidgen)
%post
# Install
apt-get -y update
export R_VERSION=4.1.3
echo "export R_VERSION=${R_VERSION}" >> $SINGULARITY_ENVIRONMENT
# Install R
apt-get update
apt-get install -y --no-install-recommends software-properties-common dirmngr wget uuid-runtime
wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | \
tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc
add-apt-repository \
"deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/"
apt-get install -y --no-install-recommends \
r-base=${R_VERSION}* \
r-base-core=${R_VERSION}* \
r-base-dev=${R_VERSION}* \
r-recommended=${R_VERSION}* \
r-base-html=${R_VERSION}* \
r-doc-html=${R_VERSION}* \
libcurl4-openssl-dev \
libssl-dev \
libxml2-dev \
libcairo2-dev \
libxt-dev \
libopenblas-dev
# Add a default CRAN mirror
echo "options(repos = c(CRAN = 'https://cran.rstudio.com/'), download.file.method = 'libcurl')" >> /usr/lib/R/etc/Rprofile.site
# Fix R package libpaths (helps RStudio Server find the right directories)
mkdir -p /usr/lib64/R/etc
echo "R_LIBS_USER='/usr/lib64/R/library'" >> /usr/lib64/R/etc/Renviron
echo "R_LIBS_SITE='${R_PACKAGE_DIR}'" >> /usr/lib64/R/etc/Renviron
# Clean up
rm -rf /var/lib/apt/lists/*
# Install python3
apt-get -y install python3 wget
apt-get -y clean
/bin/bash <<EOF
# Install reticulate and text
Rscript -e 'install.packages("reticulate")'
Rscript -e 'install.packages("devtools")'
Rscript -e 'install.packages("glmnet")'
Rscript -e 'devtools::install_github("oscarkjell/text")'
# Create the Conda environment at a system folder
Rscript -e 'text::textrpp_install(prompt = FALSE)'
Rscript -e 'text::textrpp_initialize(save_profile = TRUE, prompt = FALSE, textEmbed_test = TRUE)'
EOF
I managed to get it to work by installing Miniconda before installing the text-package (see the Install Miniconda section below).
Bootstrap: docker
From: ubuntu:20.04
%environment
export LANG=C.UTF-8 LC_ALL=C.UTF-8
export XDG_RUNTIME_DIR=/tmp/.run_$(uuidgen)
%post
# Install
apt-get -y update
export R_VERSION=4.1.3
echo "export R_VERSION=${R_VERSION}" >> $SINGULARITY_ENVIRONMENT
# Install R
apt-get update
apt-get install -y --no-install-recommends software-properties-common dirmngr wget uuid-runtime
wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | \
tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc
add-apt-repository \
"deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/"
apt-get install -y --no-install-recommends \
r-base=${R_VERSION}* \
r-base-core=${R_VERSION}* \
r-base-dev=${R_VERSION}* \
r-recommended=${R_VERSION}* \
r-base-html=${R_VERSION}* \
r-doc-html=${R_VERSION}* \
libcurl4-openssl-dev \
libssl-dev \
libxml2-dev \
libcairo2-dev \
libxt-dev \
libopenblas-dev
# Add a default CRAN mirror
echo "options(repos = c(CRAN = 'https://cran.rstudio.com/'), download.file.method = 'libcurl')" >> /usr/lib/R/etc/Rprofile.site
# Fix R package libpaths (helps RStudio Server find the right directories)
mkdir -p /usr/lib64/R/etc
echo "R_LIBS_USER='/usr/lib64/R/library'" >> /usr/lib64/R/etc/Renviron
echo "R_LIBS_SITE='${R_PACKAGE_DIR}'" >> /usr/lib64/R/etc/Renviron
# Clean up
rm -rf /var/lib/apt/lists/*
# Install python3
apt-get -y install python3 wget
apt-get -y clean
# Install Miniconda
cd /
wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh -b -p /miniconda
/bin/bash <<EOF
rm Miniconda3-latest-Linux-x86_64.sh
source /miniconda/etc/profile.d/conda.sh
conda update -y conda
# Install reticulate and text
Rscript -e 'install.packages("reticulate")'
Rscript -e 'install.packages("devtools")'
Rscript -e 'install.packages("glmnet")'
Rscript -e 'devtools::install_github("oscarkjell/text")'
# Create the Conda environment at a system folder
Rscript -e 'text::textrpp_install(prompt = FALSE)'
Rscript -e 'text::textrpp_initialize(save_profile = TRUE, prompt = FALSE, textEmbed_test = TRUE)'
EOF
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
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!
I got a solution for that
RUN
sudo \
libgdal-dev \
libproj-dev \
libgeos-dev \
libudunits2-dev \
netcdf-bin \
Install these dependencies
I'm trying to install an old version of RODBC into my dockerfile (I'm using R 3.6.3 and the newest version of RODBC needs R v4) by downloading the package using curl and then installing using install.packages but I'm getting the below error. Any ideas of how to achieve this?
Error: unexpected symbol in "install.packages(RODBC_1.2-6.tar.gz"
In the dockerfile I try to do the above with the following RUN statements:
RUN curl https://cran.r-project.org/src/contrib/Archive/RODBC --output RODBC_1.2-6.tar.gz
RUN R -e "install.packages(RODBC_1.2-6.tar.gz)"
The full dockerfile is:
FROM ubuntu:bionic
RUN useradd docker \
&& mkdir /home/docker \
&& chown docker:docker /home/docker \
&& addgroup docker staff
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
software-properties-common \
ed \
less \
locales \
vim-tiny \
wget \
ca-certificates \
&& add-apt-repository --enable-source --yes "ppa:marutter/rrutter3.5" \
&& add-apt-repository --enable-source --yes "ppa:marutter/c2d4u3.5"
## Configure default locale, see https://github.com/rocker-org/rocker/issues/19
RUN echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen \
&& locale-gen en_US.utf8 \
&& /usr/sbin/update-locale LANG=en_US.UTF-8
ENV LC_ALL en_US.UTF-8
ENV LANG en_US.UTF-8
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
littler \
r-base \
r-base-dev \
r-recommended \
&& ln -s /usr/lib/R/site-library/littler/examples/install.r /usr/local/bin/install.r \
&& ln -s /usr/lib/R/site-library/littler/examples/install2.r /usr/local/bin/install2.r \
&& ln -s /usr/lib/R/site-library/littler/examples/installGithub.r /usr/local/bin/installGithub.r \
&& ln -s /usr/lib/R/site-library/littler/examples/testInstalled.r /usr/local/bin/testInstalled.r \
&& install.r docopt \
&& rm -rf /tmp/downloaded_packages/ /tmp/*.rds \
&& rm -rf /var/lib/apt/lists/*
RUN apt-get update
#These are all required, the exact version, for SQL Server to work
RUN apt-get install -y gnupg2 libssl1.0 libssl1.0-dev apt-transport-https
RUN apt-get install -y libcurl4-openssl-dev curl
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN curl https://packages.microsoft.com/config/ubuntu/18.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
RUN apt-get update
RUN ACCEPT_EULA=Y apt-get install -y msodbcsql17 unixodbc unixodbc-dev
RUN apt-get install -y libssl-dev
RUN install.r tidyr bigrquery dplyr sqldf readr httr uuid
RUN curl https://cran.r-project.org/src/contrib/Archive/RODBC --output RODBC_1.2-6.tar.gz
RUN R -e "install.packages(RODBC_1.2-6.tar.gz)"
COPY src/upload_v2.r /usr/local/src/scripts/upload_v2.r
WORKDIR /usr/local/src/scripts
It looks like quote is missing in RUN R line:
RUN curl https://cran.r-project.org/src/contrib/Archive/RODBC --output RODBC_1.2-6.tar.gz
RUN R -e "install.packages('RODBC_1.2-6.tar.gz')"