我目前正试图让我的 r 应用程序通过 shinyproxy 结合 docker 运行 - 不幸的是没有成功。
该应用程序通过 R-Studio 启动时可以正常运行。但是,一旦我创建 Docker 映像并尝试调用它,我就会收到错误消息“ function %>% not found ”。
我认为包没有正确加载,但我不能说为什么。在我的 Docker 文件中,我引用了一个“installLibrarys.R”文件,其中包含应用程序所需的所有库。我还调整了 rProfile 文件,以便每个 R 会话都应该加载所有库。
使用一个不太广泛的类似应用程序(但具有几乎相同的 dockerfile 以及 applications.yml),通过 shinyproxy 和 docker 托管工作没有任何问题....
da 你可以在文章末尾找到我的 Docker 文件、我的 Rprofile.site、我的 application.yml 和我的 installLibrarys.R。
也许有人知道我还能做什么。如果您需要更多信息,请随时与我联系!:-)
感谢你并致以真诚的问候
PS:我知道许多库都“包含”在其他库中并且不必要地加载了-我还没有时间进行排序: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")
安装包.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')"]
应用程序.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