├── .gitignore ├── .travis.yml ├── Dockerfile ├── README.md ├── app ├── main.py └── uwsgi.ini └── requirements.txt /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | venv -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | 3 | env: 4 | global: 5 | # Ubuntu version 6 | - LINUX_DIST=trusty 7 | - DEPS_DIR=${TRAVIS_BUILD_DIR}/deps 8 | 9 | matrix: 10 | include: 11 | - os: linux 12 | dist: trusty 13 | sudo: required 14 | compiler: gcc 15 | addons: 16 | apt: 17 | packages: &precise_latest_boost_packages 18 | - git 19 | - python-yaml 20 | - apt-transport-https 21 | - ca-certificates 22 | - curl 23 | - software-properties-common 24 | sources: &precise_latest_boost_sources 25 | - ubuntu-toolchain-r-test 26 | - llvm-toolchain-precise-3.7 27 | 28 | install: 29 | - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - 30 | - sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu(lsb_release -cs)stable" 31 | - sudo apt-get update 32 | - sudo apt-get install docker-ce 33 | 34 | script: 35 | ############################################################################ 36 | # Build 37 | ############################################################################ 38 | - docker build -t my_dashboard . -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM tiangolo/uwsgi-nginx-flask:python3.6 2 | LABEL maintainer="maintainer" 3 | 4 | COPY requirements.txt /tmp/ 5 | COPY ./app /app 6 | 7 | RUN pip install -U pip && pip install -r /tmp/requirements.txt 8 | 9 | ENV NGINX_WORKER_PROCESSES auto -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Dash - nginx - uWSGI - Docker 2 | 3 | Dash by Plotly is a Python framework to build elegant interactive dashboards for the web. This template can be used to create a Docker image that uses Flask, Nginx, and uWSGI to serve the application. 4 | 5 | ## Dockerize your Dash app 6 | 7 | 1. Create Docker image 8 | ``` 9 | docker build -t my_dashboard . 10 | ``` 11 | 12 | 2. Run app in container 13 | ``` 14 | docker run -p 8080:80 my_dashboard 15 | ``` 16 | This will run the app on http://localhost:8080/. 17 | 18 | The base image used in the Dockerfile: https://hub.docker.com/r/tiangolo/uwsgi-nginx-flask/. -------------------------------------------------------------------------------- /app/main.py: -------------------------------------------------------------------------------- 1 | import dash 2 | import dash_html_components as html 3 | import flask 4 | 5 | app = flask.Flask(__name__) 6 | dash_app = dash.Dash(__name__, server = app, url_base_pathname = '/') 7 | 8 | dash_app.css.append_css({"external_url" : "https://codepen.io/chriddyp/pen/bWLwgP.css"}) 9 | 10 | colors = { 11 | 'background' : '#111111', 12 | 'text' : '#7FDBFF' 13 | } 14 | 15 | 16 | dash_app.layout = html.Div( 17 | [ 18 | html.Div( 19 | [ 20 | html.H1( 21 | "My Dashboard", 22 | style={ 23 | 'text-align':'center', 24 | } 25 | ), 26 | ], 27 | ) 28 | ], 29 | ) 30 | 31 | 32 | if __name__ == '__main__': 33 | app.run(host='0.0.0.0', debug=True, port=80) -------------------------------------------------------------------------------- /app/uwsgi.ini: -------------------------------------------------------------------------------- 1 | [uwsgi] 2 | module = main 3 | callable = app 4 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | dash==1.0.0 2 | dash-daq==0.1.0 --------------------------------------------------------------------------------