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
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.
Related
I'm trying to publish some panels on Shiny Server with Kubernetes, but I'm struggling with R packets that are not installed on the server.The panels are working on my test environment on AWS (without K8s). The error is below detailed.
> su: ignoring --preserve-environment, it’s mutually exclusive with --login
> Error in library(“shinyWidgets”) :
> there is no package called ‘shinyWidgets’
> Calls: runApp ... sourceUTF8 -> eval -> eval -> ..stacktraceon.. -> library
> Execution halted
As commented in the code, many alternative options to install the R packets were tried without success.
FROM rocker/shiny-verse:latest
USER root
# Finding required libraries. Libraries should be installed in /usr/share/doc
# pak::pkg_system_requirements(“dplyr”, “ubuntu”, “20.04")
# Packects should be installed in /usr/local/lib/R/site-library
# Install system requirements for index.R as needed
RUN apt-get update -qq \
&& apt-get -y --no-install-recommends install \
gdal-bin \
gsfonts \
imagemagick \
libavfilter-dev \
libcurl4-openssl-dev \
libgdal-dev \
libgeos-dev \
libicu-dev \
libjq-dev \
libmagick++-dev \
libnode-dev \
libpng-dev \
libproj-dev \
libprotobuf-dev \
libsqlite3-dev \
libssl-dev \
libudunits2-dev \
make \
protobuf-compiler \
zlib1g-dev \
lbzip2 \
libgeos-c1v5 \
libxml2-dev \
sudo \
pandoc \
pandoc-citeproc \
libcairo2-dev \
libxt-dev \
libssh2-1-dev \
littler \
proj-bin
# Install Tree
RUN apt-get install -y tree
RUN install2.r --error --deps TRUE \
data.table \
dplyr \
geobr \
rgeos \
geojsonio \
ggplot2 \
ggrepel \
ggthemes \
grid \
magick \
magrittr \
pak \
plotly \
png \
readr \
rmapshaper \
shinyBS \
shinycssloaders \
shinyWidgets \
sp \
&& rm -rf /tmp/downloaded_packages
# I also tried to install using these packages with either no success.
# install R packages required
# RUN R -e “install.packages(‘shinyWidgets’, repos=‘http://cran.rstudio.com/’)”
# RUN R -q -e ‘pak::local_install(“shinyWidgets”)’
## assume shiny app is in build folder /shiny
COPY ./cenarios/* /srv/shiny-server/
COPY ./log/shiny-server/ /var/log/shiny-server/
# USER shiny
# allow permission
# RUN sudo chown -R shiny:shiny /srv/shiny-server
# run app
CMD [“/usr/bin/shiny-server”]
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'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.
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')"
I'm trying to connect to a remoter server and getting the following error:
Error in sodium::auth_decrypt(encrypted, getkey(private), getkey(theirs)) :
is.raw(nonce) is not TRUE
In addition: Warning message:
In unserialize(rmsg) :
cannot unserialize ALTVEC object of class 'wrap_raw' from package 'base'; returning length zero vector
If I run the server with secure = FALSE everything works as expected. This is the dockerfile that i'm using to run the server:
FROM rocker/r-ubuntu:18.04
# Install dependencies
RUN apt-get update -qq && apt-get install -y \
libsodium-dev \
libxml2-dev \
libssl-dev \
libcurl4-openssl-dev \
r-cran-tidyverse \
r-cran-remotes \
r-cran-rstan \
r-cran-rstanarm \
r-cran-rstan \
&& install.r \
remoter \
sodium \
drat \
RcppArmadillo \
RcppEigen \
StanHeaders \
aws.signature \
aws.s3
COPY R/Makevars /root/.R/Makevars
RUN mkdir -p /root/.ssh
VOLUME [ "/root/.ssh" ]
CMD ["R", "-e", "remoter::server(port = 49152, secure = T, password=Sys.getenv('api_key'))"]
Is this a bug in the remoter package or am I doing something wrong?