Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Plotly dash in docker不加载资源_Docker_Plotly_Wsgi_Plotly Dash_Waitress - Fatal编程技术网

Plotly dash in docker不加载资源

Plotly dash in docker不加载资源,docker,plotly,wsgi,plotly-dash,waitress,Docker,Plotly,Wsgi,Plotly Dash,Waitress,我有一个多页dash应用程序,在本地运行时,它可以按预期工作: 女服务员服务--listen=0.0.0.0:80 web_app.wsgi:application 因此,assets文件夹中的所有资产都被正确加载,图像被加载为src=app.get\u asset\u url('xyz.png'),并将app.css.config.service\u locally设置为true,如图所示,所有内容都被加载 但是当在docker容器中加载相同的应用程序时,不会加载资源,因此本地css也不会加载

我有一个多页dash应用程序,在本地运行时,它可以按预期工作:

女服务员服务--listen=0.0.0.0:80 web_app.wsgi:application

因此,assets文件夹中的所有资产都被正确加载,图像被加载为
src=app.get\u asset\u url('xyz.png')
,并将
app.css.config.service\u locally
设置为
true
,如图所示,所有内容都被加载

但是当在docker容器中加载相同的应用程序时,不会加载资源,因此本地css也不会加载

已经检查了docker中的文件和文件夹,所有内容都符合预期

我想我在某个地方遗漏了一些东西,但没有找到什么,关于如何让它工作的任何建议

Dockerfile

FROM python:3

RUN apt-get update && apt-get install -qq -y \
build-essential libpq-dev --no-install-recommends

ENV INSTALL_PATH /gtg_analytics-master
ENV PYTHONPATH "${PYTHONPATH}:$INSTALL_PATH/web_app"
RUN mkdir -p $INSTALL_PATH

WORKDIR $INSTALL_PATH

COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt

COPY web_app $INSTALL_PATH/web_app
docker compose:

version: "3"

services:
web_app:
image: patber/gtg:dev
build: .
command: >
  waitress-serve --listen=0.0.0.0:80
  web_app.wsgi:application
environment:
  PYTHONUNBUFFERED: 'true'
volumes:
  - '.:/web_app'
ports:
  - '80:80'

找到了CSS文件的解决方案


我遇到了相同的问题,这里提供的解决方案是正确的,但您还需要添加:

app.css.config.serve_locally = False
此外,您可以通过以下方式添加样式表,而不是附加:

external_stylesheets=["./assets/stylesheet.css"]
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)

这不是很好,但如果您需要提供css以外的服务,也可以使用外部源选项:

app = dash.Dash(
    __name__,
    assets_external_path='http://your-external-assets-folder-url/'
)

我遇到了一个图像,这是我知道的最好的(当前=1月30日'20)解决方案。

你能分享一下你是如何构建docker图像的吗?更新了docker文件的帖子
app = dash.Dash(
    __name__,
    assets_external_path='http://your-external-assets-folder-url/'
)