Skip to content

PyBites-Open-Source/pybitesbooks

Repository files navigation

PyBites Books

What gets measured gets managed. - Peter Drucker

Our simple yet effective reading tracking app: PyBites Books

(Warning: it can be addictive and will cause you to read more!)

Setup

pre-commit

  1. Create a virtual env and activate it (source venv/bin/activate)
  2. Install the dependencies: pip install -r requirements.txt
  3. Create a database, e.g. pybites_books and define the full DB URL for the next step, e.g. DATABASE_URL=postgres://postgres:[email protected]:5432/pybites_books.
  4. Set this env variable together with SECRET_KEY in a file called .env in the root of the project: cp .env-template .env && vi .env. That's the bare minimum. If you want to have email working create a Sendgrid account obtaining an API key. Same for Slack integration, this requires a SLACK_VERIFICATION_TOKEN. The other variables have sensible defaults.
  5. Sync the DB: python manage.py migrate.
  6. And finally run the app server: python manage.py runserver.

Run pre-commit

Install the git hook scripts

 pre-commit install

Run against all the files:

 pre-commit run --all-files

Local Via docker-compose

You can use docker / docker compose to run both the postgresql database as well as the app itself. This makes local testing a lot easier, and allows you to worry less about environmental details.

To run, simply run the below command. This should spin up the db, and then the application which you can reach at http://0.0.0.0:8000.

docker-compose rm && docker-compose build && docker-compose up

DB Data

In order to prevent recreating the DB every time you run docker-compose, and in order to keep state from use to use, a volume is mounted, and tied to the local directory database-data. This is ignored in the .gitignore so that you don't accidentally upload data to github.

.env-compose

This has environment variables set so that you can get up and running easily. Tweak these as needed to add things like Slack and SendGrid integration.

Contributions

... are more than welcome, just open an issue and/or PR new features.

Remember leaders are readers, read every day!