Home > OS >  Plotly Dash css not available with docker
Plotly Dash css not available with docker

Time:01-02

I am trying to run a dash app with docker. When I run my app locally (without docker) the css stylesheet is recognized correctly. Running the dash app with docker results in the default style without applying the changes specified in the stylesheet. My Dockerfile looks as following:

FROM python:3.9

ENV APP_HOME /app
WORKDIR $APP_HOME
COPY static app.py requirements.txt ./

RUN apt-get update
RUN apt-get install ffmpeg libsm6 libxext6  -y
RUN pip install -r requirements.txt

EXPOSE 8080

CMD python app.py

app.py contains the dash app, while the stylesheet is located in the folder 'static'. Currently I load the stylesheet like this:

from dash import Dash

app = Dash(__name__)
app.css.config.serve_locally = False
app.css.append_css({'external_url': './static/style.css'})

I have tried the solutions recommended here. However, none of them work for me. Grateful for any suggestions you have to solve this.

CodePudding user response:

Turns out explicitly copying the file does the trick. Just added the following line to the Dockerfile:

COPY static/style.css /app/static/style.css
  • Related