我正在尝试使用ShinyProxy启动闪亮的应用程序-我之前已经做过很多次了。但是,此应用未正确使用运行它所需的任何CSS或JS文件。
当我使用docker run -p 3838:3838 my_app
手动运行该应用程序时,一切正常。但是,将ShinyProxy指向my_app图像时,生成的应用程序无法加载任何CSS或JS文件。
Dockerfile
FROM openanalytics/r-base
MAINTAINER Daniel Beachnau "DannyBeachnau@gmail.com"
# Dependencies outside of R
RUN apt-get update && apt-get install -y \
sudo \
gdebi-core \
pandoc \
pandoc-citeproc \
libcurl4-gnutls-dev \
libcairo2-dev \
libxt-dev \
xtail \
wget \
libpq-dev \
libmariadb-client-lgpl-dev \
# Might be needed for the archivist R-Library
dbus \
systemd \
# needed for odbc
unixodbc-dev
RUN apt-get install apt-transport-https curl -y
RUN curl http://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
RUN apt-get update
RUN ACCEPT_EULA=Y apt-get install msodbcsql17 -y
# Download R-Packages
# tidyverse
RUN R -e "install.packages('tidyr')"
RUN R -e "install.packages('dplyr')"
RUN R -e "install.packages('readr')"
# Shiny Packages
RUN R -e "install.packages('shiny')"
RUN R -e "install.packages('shinycssloaders')"
RUN R -e "install.packages('shinydashboard')"
RUN R -e "install.packages('shinyWidgets')"
RUN R -e "install.packages('DT')"
RUN R -e "install.packages('shinyjs')"
RUN R -e "install.packages('flexdashboard')"
# Database Packages
RUN R -e "install.packages('odbc')"
RUN R -e "install.packages('RMySQL')"
# Other
RUN R -e "install.packages('devtools')"
RUN R -e "install.packages('lubridate')"
RUN R -e "install.packages('reshape2')"
RUN R -e "install.packages('grid')"
RUN R -e "install.packages('lemon')"
RUN R -e "install.packages('scales')"
RUN R -e "install.packages('ggthemes')"
RUN R -e "install.packages('ggplot2')"
RUN R -e "devtools::install_bitbucket(repo = 'my_repo/my_package', auth_user = 'my_username', password = 'my_password')"
# copy the app to the image
COPY . /root
# run the script to update the app data
WORKDIR /root
RUN Rscript app_data_update.R
WORKDIR /root/app
COPY Rprofile.site /usr/lib/R/etc/
EXPOSE 3838
CMD ["R", "-e", "shiny::runApp('/root/app', host='0.0.0.0', port=3838)"]
application.yml
shiny:
proxy:
title: ShinyProxy Server
logo-url: /images/logo-image.png
landing-page: /
heartbeat-rate: 10000
heartbeat-timeout: 60000
container-wait-time: 60000
port: 8080
authentication: ldap
# Docker configuration
docker:
cert-path: /home/none
url: http://localhost:2375
port-range-start: 20000
support:
container-log-path: ./container-logs
mail-to-address: DannyBeachnau@gmail.co,
- name: my_apps_name
display-name: Shiny App
docker-image: dbeachnau/my_app
groups: [Shiny Users Management]
logo-url: /images/logo-image.png
container-volumes: ["/path/to/app:/root/app"]
logging:
file:
shinyproxy.log
这是应用在闪亮的代理中的外观。
这是我的应用在手动运行时看上去的样子。
chrome的检查工具中的控制台充满了诸如
之类的错误 GET https://myshinyserver.com/container_name/font-awesome-5.3.1/css/all.min.css net::ERR_ABORTED 404 (Not Found)
我确实在ShinyProxy上运行了其他应用程序,这些应用程序可以正常显示,但是我无法解决这些应用程序配置与该应用程序配置之间的区别。让我知道是否需要其他详细信息来诊断问题。感谢所有反馈-谢谢。
答案 0 :(得分:0)
您将必须在Dockerfile的顶部安装所需的字体。您可以将其添加到列表“ R之外的依赖项”:
sudo apt-get install fonts-font-awesome
答案 1 :(得分:0)
我已经解决了我的问题,尽管这仍然不能算作足够的答案或解释,因为我无法解释这种解决方案为何有所作为。我决定使用现在可以使用的其他基础映像重写Dockerfile。我的代码中没有其他更改-仅是Dockerfile。工作的docker文件如下:
FROM rocker/shiny-verse
# based on debian 9
MAINTAINER Daniel Beachnau "DannyBeachnau@gmail.com"
# Dependencies outside of R
RUN apt-get update && apt-get install -y \
gnupg2 \
apt-utils \
sudo \
gdebi-core \
libxt-dev \
xtail \
wget
# Install ODBC driver from microsoft
RUN apt-get install apt-transport-https curl -y
RUN curl http://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN curl https://packages.microsoft.com/config/debian/9/prod.list > /etc/apt/sources.list.d/mssql-release.list
RUN apt-get update
RUN ACCEPT_EULA=Y apt-get install msodbcsql17 -y
# Download R-Packages
# Shiny Packages
RUN R -e "install.packages('shinycssloaders')"
RUN R -e "install.packages('shinydashboard')"
RUN R -e "install.packages('shinyWidgets')"
RUN R -e "install.packages('DT')"
RUN R -e "install.packages('shinyjs')"
RUN R -e "install.packages('flexdashboard')"
# Database Packages
RUN R -e "install.packages('odbc')"
RUN R -e "install.packages('RMySQL')"
# Other
RUN R -e "install.packages('lubridate')"
RUN R -e "install.packages('reshape2')"
RUN R -e "install.packages('scales')"
RUN R -e "install.packages('ggthemes')"
RUN R -e "install.packages('ggplot2')"
RUN R -e "devtools::install_bitbucket(repo = 'my_repo', auth_user = 'my_username', password = 'my_password')"
# copy the app to the image
COPY . /root
# run the script to update the app data
WORKDIR /root
RUN Rscript app_data_update.R
WORKDIR /root/app
COPY Rprofile.site /usr/lib/R/etc/
EXPOSE 3838
CMD ["R", "-e", "shiny::runApp('/root/app', host='0.0.0.0', port=3838)"]
如果有人对为什么会观察到这种行为有深刻的了解,我很乐意听到它,因为我不敢多说。
答案 2 :(得分:0)
您可能会在Shiny v1.3.0(而不是早期版本)中看到这种情况。如果是这样,可能是由于您的NGINX代理指令中的配置错误。我已经写了详细信息here,但我还将在此处发布重要的详细信息。
proxy_set_header Connection "upgrade";
此指令使NGINX在仅应用于WebSocket时向每个HTTP请求添加一个Connection:升级标头。
NGINX Inc.本身推荐此行,但是,这些建议仅用于代理WebSockets的流量,而Shiny流量则是普通HTTP请求和WebSockets的组合。较旧版本的Shiny / httpuv不介意这种情况,但是新版本更严格。
正确的配置如下所示:
http {
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80;
location / {
proxy_pass http://localhost:3838;
proxy_redirect / $scheme://$http_host/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_read_timeout 20d;
proxy_buffering off;
}
}
}
有关其他示例,请参见RStudio Community post中链接的文章。
答案 3 :(得分:-1)