Skip to content

drewdru/fastDrewDru

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

84 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fastDrewDru

Backend for personal website(drewdru.com) and fun

Microservices

Frontend repository: https://github.com/drewdru/sitedrewdru

Dependencies

  1. Python >= 3.8.0
  2. requiremets.txt
  3. PostgreSql
  4. Redis
  5. Nginx

Local Deployment

Configure project

Create and configure .env file:

cp .env.example .env && cp .env.example .env.test && cp .env.example .env.ci
# if you use Docker: && cp .env.example .env.docker

To get a string for SECRET_KEY run:

openssl rand -hex 32

Build dependencies

virtualenv env -p python3
source env/bin/activate
pip install -r requirements.txt

Migrate

python manage.py migrations upgrade head

Manage progect

Run project

python manage.py run [--prod]

Run tests

python manage.py test

Add new microservice

python manage.py createapp microservice_name

Run migrations commands

python manage.py migrations -h [--prod]
# Autogenerate migrations
python manage.py migrations revision --autogenerate -m "Autogenerate migrations" [--prod]

Deployment

Change enviromet variables in .env.prod

cp .env.example .env.prod && cp .env.example .env.test

Build dependencies

virtualenv env -p python3
source env/bin/activate
pip install -r requirements.txt

Migrate

python manage.py migrations upgrade head

Run systemd service

Configure paths in etc/fastDrewDru.service

sudo cp etc/fastDrewDru.service /etc/systemd/system/fastDrewDru.service
sudo systemctl daemon-reload
sudo systemctl start fastDrewDru.service
sudo systemctl enable fastDrewDru.service
sudo service fastDrewDru status # use restart on deploy

Configure NGINX

Configure paths in etc/nginx/sites-available/fastDrewDru.conf

sudo cp etc/nginx/sites-available/fastDrewDru.conf /etc/nginx/sites-available/fastDrewDru.conf
sudo ln -s /etc/nginx/sites-available/fastDrewDru.conf /etc/nginx/sites-enabled/fastDrewDru.conf
sudo service nginx reload