Deploy Plotly Dash app with Dash DAQ components on AWS cloud
To share a Dash app, you need to “deploy” your Dash app to a server. The guide below works for Dash application with and without Dash DAQ components. We’ll deploy app on AWS in easiest way.
Dash “Hello, World!”
Let’s create new directory (e.g., medium
). Create new application.py
file with code below:
Note: Line app.scripts.config.serve_locally = True
is required for Dash DAQ components.
Python dependencies
Navigate to project directory (e.g., medium
)and create new requirements.txt
file with code below:
AWS Elastic Beanstalk
AWS Elastic Beanstalk is an easy-to-use service for deploying and scaling web applications and services developed with Python.
Install the Elastic Beanstalk Command Line Interface (EB CLI):
$ sudo pip install awsebcli
If you want install EB CLI on Amazon Linux, use instruction below:
$ sudo yum update$ sudo yum install git
$ sudo yum groupinstall "Development Tools"
$ sudo yum install libffi-devel openssl-devel$ git clone https://github.com/aws/aws-elastic-beanstalk-cli-setup.git
$ ./aws-elastic-beanstalk-cli-setup/scripts/bundled_installer$ echo 'export PATH="/home/ec2-user/.ebcli-virtual-env/executables:$PATH"' >> ~/.bash_profile && source ~/.bash_profile$ rm -rf aws-elastic-beanstalk-cli-setup
Initiate EB
Navigate to project directory (e.g., medium
) and initialize your directory with the EB CLI:
$ eb init
Select a default region (e.g., eu-west-1
). Enter application name (e.g., medium
).
It appears you are using Python. Is this correct?
(Y/n):
Enter Y
.
Select Python version (e.g., Python 3.6
).
Do you want to set up SSH for your instances?
(Y/n):
Enter n
.
Deploy Dash app
Create a new environment:
$ eb create
Enter environment name (e.g., medium-dev
). Enter DNS CNAME prefix (e.g., medium-dev
). Select a load balancer type (e.g., application
).
Open the application URL in a browser:
$ eb open
Update Dash app
Let’s update Dash app. Change:
html.H1('Hello, World!')
line to:
html.H1('Hello, Medium!')
Deploy new source code to the environment:
$ eb deploy
Open the application URL in a browser:
$ eb open
Delete Dash app from AWS cloud
Terminate the environment:
$ eb terminate