Jump to content

Plotly Dash

From Sinfronteras



Deploying a Dash App

https://dash.plot.ly/deployment


Dash uses Flask under the hood. This makes deployment easy: you can deploy a Dash app just like you would deploy a Flask app. Almost every cloud server provider has a guide for deploying Flask apps. There is also a Dash Deployment Server, but is not free (commercial).

  • Flask Deployment
  • Dash Deployment Server (commercial)



Flask Deployment

sudo vi /etc/systemd/system/sentiment-dash.service

[Unit]
Description=sentiment-dash
After=network.target

[Service]
User=ubuntu
Group=www-data
WorkingDirectory=/var/www/sinfronteras/sentiment-dash
Environment="PATH=/var/www/sinfronteras/sentiment-dash/.venv/bin"
ExecStart=/var/www/sinfronteras/sentiment-dash/.venv/bin/gunicorn --workers 3 --bind unix:index.sock -m 007 wsgi:server

[Install]
WantedBy=multi-user.target


sudo vi /etc/nginx/sites-available/sentiment-dash.sinfrontera.net

server {
    listen 443 ssl http2;
    server_name sentiment-dash.sinfrontera.net;

    ssl_certificate /etc/letsencrypt/live/sentiment-dash.sinfrontera.net/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/sentiment-dash.sinfrontera.net/privkey.pem;

    location / {
        proxy_pass http://unix:/var/www/sinfronteras/sentiment-dash/index.sock;

        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

server {
    listen 80;
    server_name sentiment-dash.sinfrontera.net;
    return 301 https://$host$request_uri;
}