abbasidaniyal / CBS

Home Page:https://connectbuild.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Deployment Steps

First time setup

  1. Update system
sudo apt update && sudo apt upgrade
  1. Install python, python-venv, postgresql (local database)
sudo apt install python3.9 python3.9-venv python3.9-dev postgresql nginx
  1. Configure postgresql Create user/password
sudo su postgres
psql
create user <USERNAME> with encrypted password '<PASSWORD>';

Create database

create database cbs-website-db
GRANT ALL PRIVILEGES ON DATABASE cbs-website-db TO <USERNAME>;
  1. Make system user
sudo adduser website
su website
  1. Make dir and clone code
mkdir website
git clone https://github.com/abbasidaniyal/CBS.git website
  1. Create venv and install requirements
cd website
python3.9 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
  1. Setup secrets
cp .env_sample .env

Fill in the required values in .env file

  1. Test run
python manage.py migrate
python manage.py collectstatic
python manage.py runserver
gunicorn --bind 0.0.0.0:8000 cbs.wsgi
  1. Create superadmin
python manage.py createsuperuser
  1. Create deamon job Switch to user with sudo permission

Create service file

cp deploy/website.service /etc/systemd/system/website.service

Start and enable website

sudo systemctl start website
sudo systemctl enable website

Check status sudo systemctl status gunicorn

To see logs

sudo journalctl -u website

To propogate changes

sudo systemctl daemon-reload
sudo systemctl restart gunicorn
  1. Setup nginx Copy conf from deploy/nginx.conf and add to /etc/nginx/sites-available/website

Enable available site

sudo cp deploy/nginx.conf /etc/nginx/sites-available/website
sudo ln -s /etc/nginx/sites-available/website /etc/nginx/sites-enabled

Restart to propogate changes

sudo systemctl restart nginx
  1. SSL encryption Install python certbot
sudo apt-get install python3-certbot-nginx

Configure firewall

sudo ufw allow 'Nginx Full'

Set dns entries to the IP of the machine

Get certificate

sudo certbot --nginx -d connectbuild.com -d www.connectbuild.com

Note: Setup http to https redirect

Updating code

  1. Pull new code
su website
cd website
git pull origin master
  1. Update requirements and run migrations
pip install -r requirements.txt
python manage.py collectstatic  --noinput
python manage.py migrate  --noinput
  1. Restart service
sudo systemctl restart website.service

About

https://connectbuild.com


Languages

Language:CSS 36.3%Language:HTML 34.2%Language:Python 17.1%Language:JavaScript 12.2%Language:Shell 0.2%