- Linux/MacOS/WSL 2
- Python3
- PostgreSQL database up and running
- Install and configure docker
- Create linux user 'postgres', ensure it has the '/home/postgres' directory
- Add the 'postgres' user to the 'docker' group
sudo usermod -aG docker postgres
- Create the 'postgres_data' directory as we will obey the 'immutable infrastructure' approach
mkdir -p /home/postgres/postgres_data
- Check the linux id of the 'postgres' user
$ id
uid=1001(postgres) gid=1002(postgres) groups=1002(postgres),1001(docker)
- Create the 'postgres_container' directory, and navigate to it
mkdir -p /home/postgres/postgres_container
cd /home/postgres/postgres_container
- Create the 'docker-compose.yml' file, remember to put your values instead of the <...> fields:
version: '3.1'
services:
db:
user: "<POSTGRES_USER_UID>:<POSTGRES_USER_GID>"
image: postgres
restart: always
environment:
POSTGRES_PASSWORD: <FIXER_USER_PASSWORD>
POSTGRES_USER: fixer
POSTGRES_DB: fixer_db
ports:
- 5432:5432
volumes:
- /home/postgres/postgres_data:/var/lib/postgresql/data
adminer:
image: adminer
restart: always
ports:
- 8080:8080
- Run the container by launching the following command inside the 'postgres_container' directory:
docker compose up
Create virtual environment in your python setup:
0. pwd -> (should return): ||SOMETHING||/Fixer
pwd
- Create and navigate to the './run' directory
mkdir -p ./run
cd ./run
- Create, configure and activate the virtual environment:
python3 -m venv venv
virtualenv -p python3 venv
source venv/bin/activate
- Install dependencies:
(venv) $ pip install flask flask-wtf flask-sqlalchemy flask-migrate psycopg2-binary flask-login email-validator flask-socketio python-dotenv elasticsearch
- Set database URL - create a new environment variable called DATABASE_URL as below, but put your database credential inside <...> fields
(venv) $ export DATABASE_URL="postgresql://fixer:<FIXER_USER_PASSWORD>@<DATABASE_IP>:5432/fixer_db"
- Initialize the database in the main directory
cd ..
(venv) flask db upgrade
(venv) $ flask run --host=0.0.0.0 -p 1990
use the port 1990 or the other that you choose :)