Developer Environment

Prerequisites Hyperlink to this header

These instructions assume you are developing BookWyrm using Docker. You'll need to install Docker and docker-compose to get started.

Setting up the developer environment Hyperlink to this header

  • Get a copy of the BookWyrm codebase from GitHub. You can create a fork of the repository, and then use git clone to download the code to your computer.
  • Go to the directory which contains the code on your computer, you'll be working from there from here on out.
  • Set up your development environment variables file by copying the dev example file (.env.dev.example) into a new file named .env. In the command line, you can do this with:
cp .env.dev.example .env
  • Optionally, you can use a service like ngrok to set up a domain name, and set the DOMAIN variable in your .env file to the domain name generated by ngrok.

  • Set up nginx for development by coping the developer nginx configuration file (nginx/development) into a new file named nginx/default.conf:

cp nginx/development nginx/default.conf
  • Start the application. In the command line, run:
docker-compose build
docker-compose run --rm web python manage.py migrate
docker-compose run --rm web python manage.py initdb
docker-compose up
  • Once the build is complete, you can access the instance at http://localhost:1333

Editing or creating Models Hyperlink to this header

If you change or create a model, you will probably change the database structure. For these changes to have effect you will need to run Django's makemigrations command to create a new Django migrations file, and then migrate it:

./bw-dev makemigrations
./bw-dev migrate

Editing static files Hyperlink to this header

If you edit the CSS or JavaScript, you will need to run Django's collectstatic command in order for your changes to have effect. You can do this by running:

./bw-dev collectstatic

If you have installed yarn, you can run yarn watch:static to automatically run the previous script every time a change occurs in bookwyrm/static directory.