~linuxgoose/bocpress

ref: 936ac6d885385d9e80ea4b9852e3d7b0390ec758 bocpress/README.md -rw-r--r-- 7.9 KiB
936ac6d8 — Jordan update readme wording 2 months ago

#Serve

To run the Django development server:

uv python manage.py runserver

If you have also configured hosts as described above in the "Set up subdomains" section, BōcPress should now be locally accessible at http://dev-bocpress.co.uk:8000/

#Testing

Using the Django test runner:

uv run python manage.py test

For coverage, run:

uv run coverage run --source='.' --omit '.venv/*' manage.py test
uv run coverage report -m

#Code linting & formatting

We use ruff for Python code formatting and linting.

To format:

uv run ruff format

To lint:

uv run ruff check
uv run ruff check --fix

#Python dependencies

We use uv to manage dependencies declared in pyproject.toml (see [project] and [dependency-groups]).

Common commands:

# Add or remove dependencies
uv add <package>
uv remove <package>

# Update locked versions and install
uv lock -U
uv sync --all-groups

#Deployment

See the Deployment document for an overview on steps required to deploy a BōcPress instance.

#Useful Commands

To reload the gunicorn process:

sudo systemctl reload bocpress

To reload Caddy:

systemctl restart caddy  # root only

gunicorn logs:

journalctl -fb -u bocpress

Caddy logs:

journalctl -fb -u caddy

Get an overview with systemd status:

systemctl status caddy
systemctl status bocpress

#Backup

See Database Backup for details. In summary:

To create a database dump:

pg_dump -Fc --no-acl bocpress -h localhost -U bocpress -f /home/deploy/bocpress.dump -w

To restore a database dump:

pg_restore -v -h localhost -cO --if-exists -d bocpress -U bocpress -W bocpress.dump

#Management

In addition to the standard Django management commands, there are also:

  • processnotifications: sends notification emails for new blog posts of existing records.
  • mailexports: emails users of their blog exports.

They are triggered using the standard manage.py Django way; eg:

python manage.py processnotifications

#Billing

One can deploy BōcPress without setting up billing functionalities. This is the default case. To handle payments and subscriptions this project uses Stripe. To enable Stripe and payments, one needs to have a Stripe account with a single Product (eg. "BōcPress Premium Plan").

To configure, add the following variables from your Stripe account to your .envrc:

export STRIPE_API_KEY="sk_test_XXX"
export STRIPE_PUBLIC_KEY="pk_test_XXX"
export STRIPE_PRICE_ID="price_XXX"

#License

Copyright Mataroa & BōcPress Contributors

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, version 3.

Forked from Mataroa