Inspired by these documents:
- https://panel.holoviz.org/user_guide/Server_Configuration.html
- https://docs.bokeh.org/en/latest/docs/user_guide/server/deploy.html
- https://simpleisbetterthancomplex.com/tutorial/2016/10/14/how-to-deploy-to-digital-ocean.html
ssh root@<ip-address>
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get -y install build-essential libpq-dev
sudo apt-get -y install nginx
sudo apt-get -y install supervisor
sudo systemctl enable supervisor
sudo systemctl start supervisor
sudo apt-get -y install python3-virtualenv
adduser <USER>
gpasswd -a <USER> sudo
su - <USER>
- Create a github Personal Access Token (classic with repo[x] priviledge): https://github.com/settings/tokens
- Clone the desired deployment project
git clone https://github.com/<username>/<project>.git
when prompted, use your github username and paste the access token for password.
virtualenv .
source bin/activate
cd <project>
pip install -r requirements.txt
panel serve <project>/app.py --port 5100 --allow-websocket-origin=<ip-address>
Go to <ip-address>:5100 in your browser
ctrl-C to close the app
cd
vim bin/panel_start
#!/bin/bash
DIR=/home/<USER>/<project>
cd $DIR
source ../bin/activate
export PYTHONPATH=$DIR:$PYTHONPATH
exec panel serve <project>/app.py --port 5100 --allow-websocket-origin=<ip-address>
# Add more for horizontal scaling
chmod u+x bin/panel_start
chmod o+rx /home/<USER>/
mkdir logs
sudo vim /etc/supervisor/conf.d/<project>.conf
[program:<project>]
command=/home/<USER>/bin/panel_start
user=<USER>
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/home/<USER>/logs/panel-error.log
Update and run Supervisor:
sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl restart <project>
sudo supervisorctl status <project>
sudo vim /etc/nginx/sites-available/<project>
upstream myapp {
least_conn; # Use the least-connected strategy
server 127.0.0.1:5100;
# Add more for horizontal scaling
}
server {
location / {
proxy_pass http://myapp;
# all other settings unchanged
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host:$server_port;
proxy_buffering off;
}
}
sudo ln -s /etc/nginx/sites-available/<project> /etc/nginx/sites-enabled/<project>
sudo rm /etc/nginx/sites-enabled/default
sudo service nginx restart
Navigate to in your browser.
If you don't see your panel app:
tail logs/panel-error.log
sudo tail /var/log/nginx/error.log
sudo tail /var/log/nginx/access.log