I am currently trying to get my r-application running via shinyproxy in combination with docker - unfortunately without success.
The app works without problems when started via R-Studio. However, as soon as I create the Docker image and try to call it, I get the error message "function %>% not found".
I think that the packages are not loaded correctly, but I can't say why. In my Docker file I refer to an "installLibrarys.R" file, which contains all the libraries I need for the app. I have also adapted the rProfile file so that every R session should load all the libraries.
With a similar app, which was less extensive (but with an almost identical dockerfile as well as applications.yml), hosting via shinyproxy and docker worked without any problems....
da You can find my Docker file, my Rprofile.site, my application.yml and my installLibrarys.R at the end of the post.
Maybe someone has an idea what else I could do. If you need more info, feel free to contact me! :-)
Thank you and best regards
P.S.: I know that many libraries are "contained" in others and loaded unnecessarily - I haven't got around to sorting yet :D
Rprofile.site
## Emacs please make this -*- R -*-
## empty Rprofile.site for R on Debian
##
## Copyright (C) 2008 - 2018 Dirk Eddelbuettel and GPL'ed
##
## see help(Startup) for documentation on ~/.Rprofile and Rprofile.site
# ## Example of .Rprofile
# options(width=65, digits=5)
# options(show.signif.stars=FALSE)
# setHook(packageEvent("grDevices", "onLoad"),
# function(...) grDevices::ps.options(horizontal=FALSE))
# set.seed(1234)
# .First <- function() cat("\n Welcome to R!\n\n")
# .Last <- function() cat("\n Goodbye!\n\n")
# ## Example of Rprofile.site
# local({
# # add MASS to the default packages, set a CRAN mirror
# old <- getOption("defaultPackages"); r <- getOption("repos")
# r["CRAN"] <- "http://my.local.cran"
# options(defaultPackages = c(old, "MASS"), repos = r)
#})
## We set the cloud mirror, which is 'network-close' to everybody, as default
local({
r <- getOption("repos")
r["CRAN"] <- "https://cloud.r-project.org"
options(repos = r)
})
library("shiny")
library("rwhatsapp")
library("dplyr")
library("stringr")
library("grid")
library("gridExtra")
library("cowplot")
library("magick")
library("ggmap")
library("stopwords")
library("tidytext")
library("stringi")
library("ggplot2")
library("tidyr")
library("lubridate")
library("ggtext")
library("lattice")
library("extrafont")
library("showtext")
library("ggfittext")
library("sysfonts")
library("png")
library("shinyBS")
library("shinyWidgets")
library("bslib")
library("shinycustomloader")
library("magrittr")
library("knitr")
installPackages.R
r = getOption("repos")
r["CRAN"] = "http://cran.us.r-project.org"
options(repos = r)
install.packages("shiny")
install.packages("rwhatsapp")
install.packages("dplyr")
install.packages("stringr")
install.packages("grid")
install.packages("gridExtra")
install.packages("cowplot")
install.packages("magick")
install.packages("ggmap")
install.packages("stopwords")
install.packages("tidytext")
install.packages("stringi")
install.packages("ggplot2")
install.packages("tidyr")
install.packages("lubridate")
install.packages("ggtext")
install.packages("lattice")
install.packages("extrafont")
install.packages("showtext")
install.packages("ggfittext")
install.packages("sysfonts")
install.packages("png")
install.packages("googleway")
install.packages("shinyBS")
install.packages("shinyWidgets")
install.packages("bslib")
install.packages("shinycustomloader")
library(shiny)
library(rwhatsapp)
library(dplyr)
library(stringr)
library(grid)
library(gridExtra)
library(cowplot)
library(magick)
library(ggmap)
library(stopwords)
library(tidytext)
library(stringi)
library(ggplot2)
library(tidyr)
library(lubridate)
library(ggtext)
library(lattice)
library(extrafont)
library(showtext)
library(ggfittext)
library(sysfonts)
library(png)
library(googleway)
library(shinyBS)
library(shinyWidgets)
library(bslib)
library(shinycustomloader)
Dockerfile
FROM rocker/r-base:latest
LABEL maintainer="USER <user@example.com>"
RUN apt-get update && apt-get install -y --no-install-recommends \
sudo \
libcurl4-gnutls-dev \
libgtk2.0-dev\
xvfb\
xauth\
xfonts-base\
libcairo2-dev \
libxt-dev \
libssl-dev \
libssh2-1-dev \
libxml2-dev \
libmagick++-dev\
&& rm -rf /var/lib/apt/lists/*
RUN install.r shiny
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 Rscript installPackages.R
RUN chown app:app -R /home/app
USER app
EXPOSE 3838
CMD ["R", "-e", "shiny::runApp('/home/app')"]
application.yml
proxy:
title: ShinyProxy
# logo-url: https://link/to/your/logo.png
landing-page: /
favicon-path: favicon.ico
heartbeat-rate: 10000
heartbeat-timeout: 600000
port: 8080
container-wait-time: 60000
admin-groups: admins
hide-navbar: true
# Docker configuration
docker:
cert-path: /home/none
url: http://localhost:2375
port-range-start: 20000
specs:
- id: 01_hello
display-name: Hello Shiny App
description: A simple reactive histogram
container-image: #######:latest
logo-url: ########
access-groups: [admins, users]
logging:
file:
shinyproxy.log
spring:
servlet:
multipart:
max-file-size: 2000MB
max-request-size: 2000MB