Skip to content

Instantly share code, notes, and snippets.

@phui
Created September 15, 2020 17:10
Show Gist options
  • Save phui/fdef8145a0937e9f5c44cf91534e49f0 to your computer and use it in GitHub Desktop.
Save phui/fdef8145a0937e9f5c44cf91534e49f0 to your computer and use it in GitHub Desktop.
BotSlayer v1.3+ supervisord setup
#!/bin/bash
### ==== setting up docker ====
# clean any existing docker packages
sudo apt-get remove docker docker-engine docker.io containerd runc
# update repo list and dependencies
sudo apt-get update
sudo apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common \
supervisor
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo apt-get update
# install most updated stable version
sudo apt-get install -y docker-ce docker-ce-cli containerd.io
# add default user into docker group
sudo usermod -aG docker ubuntu
# restart docker service to reflect the user change
sudo service docker restart
# install docker-compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.27.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
### ==== setting up reverse proxy ====
# install nginx
sudo apt-get install -y nginx
# write setting for reverse proxy
sudo echo "server {
listen 80;
server_name localhost:5000;
location / {
proxy_connect_timeout 300;
proxy_send_timeout 300;
proxy_read_timeout 300;
send_timeout 300;
proxy_pass http://localhost:5000;
}
gzip on;
gzip_types text/plain application/javascript application/x-javascript application/json text/javascript text/xml text/css;
gzip_proxied no-cache no-store private expired auth;
}" | sudo tee /etc/nginx/sites-available/default
# restart nginx service to reflect change in setting
sudo service nginx restart
# start docker at startup
sudo echo '[supervisord]
nodaemon=true
logfile=/home/ubuntu/supervisord.log
logfile_maxbytes=10485760
logfile_backups=2
redirect_stderr=true
[program:botslayer]
directory=/home/ubuntu
environment=USER="ubuntu"
command=/usr/bin/docker-compose up task stream web logtab
stdout_logfile=/home/ubuntu/run.log
stdout_logfile_maxbytes=10485760
stdout_logfile_backups=2
redirect_stderr=true
priority=100
' | sudo tee /etc/supervisor/conf.d/supervisord.conf
sudo chmod a+x /etc/supervisor/conf.d/supervisord.conf
# add swap space
sudo dd if=/dev/zero of=/swapfile bs=64M count=64
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo echo '
/swapfile swap swap defaults 0 0' >> /etc/fstab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment