Mataroa Collection list of blogs.
Feel free to open a PR on GitHub or send an email patch to ~sirodoht/[email protected].
On how to contribute using email patches see git-send-email.io.
This is a Django codebase. Check out the Django docs for general technical documentation.
The Django project is illich. There is one Django app, main, with all business logic.
Application CLI commands are generally divided into two categories, those under python manage.py
and those under make.
Using venv:
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
pip install -r requirements_dev.txtThis project also uses pip-tools for dependency management.
A file named .envrc is used to define the environment variables required for this project to
function. One can either export it directly or use direnv.
There is an example environment file one can copy as base:
cp .envrc.example .envrc.envrc should contain the following variables:
export SECRET_KEY=some-secret-key
export DATABASE_URL=postgres://illich:db-password@db:5432/illich
export EMAIL_HOST_USER=smtp-user
export EMAIL_HOST_PASSWORD=smtp-passwordWhen on production, also include the following variables (see Deployment and Backup):
export NODEBUG=1
export PGPASSWORD=db-passwordThis project uses PostgreSQL. Assuming one has set the DATABASE_URL (see above), to create the
database schema:
python manage.py migrateTo run the Django development server:
python manage.py runserverIf Docker and docker-compose are preferred, then:
- Set
DATABASE_URLin.envrctopostgres://postgres:postgres@db:5432/postgres - Run
docker-compose up -d.
The database data will be saved in the git-ignored directory / Docker volume db_data,
located in the root of the project.
Using the Django test runner:
python manage.py testFor coverage, run:
make covThe following tools are used for code linting and formatting:
To use:
make format
make lintDeployment is configured using uWSGI and nginx.
Remember to set the environment variables before starting uwsgi. Depending on the deployment
environment, this could mean directly exporting the variables or just sourcing .envrc (with all
production variables — including NODEBUG):
source .envrc
uwsgi illich.iniNote that the value of the NODEBUG variable is ignored. What matters is merely its existence
in the environment.
To automate backup, there is a script which dumps the database and uploads
it into AWS S3. The script also needs the database password as an environment variable. The
key needs to be PGPASSWORD. The backup script assumes the variable lives in .envrc like so:
export PGPASSWORD=db-passwordTo restore a dump:
pg_restore -v -h localhost -cO --if-exists -d illich -U illich -W illich.dumpTo add on cron:
0 */6 * * * /opt/apps/illich/backup-database.shThis software is licensed under the MIT license. For more information, read the LICENSE file.