Skip to content

Commit 75c49d3

Browse files
authored
Merge pull request #172 from hughrun/dev
Clarify development setup instructions
2 parents 1be4f3f + e46cab5 commit 75c49d3

File tree

2 files changed

+31
-17
lines changed

2 files changed

+31
-17
lines changed

content/contributing/install-dev.md

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
Title: Developer Environment
3-
Date: 2021-04-12
3+
Date: 2025-05-26
44
Order: 5
55
---
66

@@ -10,32 +10,46 @@ These instructions assume you are developing BookWyrm using Docker. You'll need
1010

1111
## Setting up the developer environment
1212

13-
- Get a copy of [the BookWyrm codebase from GitHub](https://github.com/bookwyrm-social/bookwyrm). You can [create a fork](https://docs.github.com/en/get-started/quickstart/fork-a-repo) of the repository, and then [use `git clone` to download the code](https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/cloning-a-repository-from-github/cloning-a-repository) to your computer.
14-
- Go to the directory which contains the code on your computer, you'll be working from there from here on out.
15-
- Set up your development environment variables file by copying the example environment file (`.env.example`) into a new file named `.env`. In the command line, you can do this with:
13+
### Get the code
14+
15+
1. Get a copy of [the BookWyrm codebase from GitHub](https://github.com/bookwyrm-social/bookwyrm). You can [create a fork](https://docs.github.com/en/get-started/quickstart/fork-a-repo) of the repository, and then [use `git clone` to download the code](https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/cloning-a-repository-from-github/cloning-a-repository) to your computer.
16+
2. Go to the directory which contains the code on your computer, you'll be working from there from here on out.
17+
3. Set up your development environment variables file by copying the example environment file (`.env.example`) into a new file named `.env`. In the command line, you can do this with:
1618
``` { .sh }
1719
cp .env.example .env
1820
```
19-
- In `.env`, change `DEBUG` to `true`
20-
- Optionally, you can use a service like [ngrok](https://ngrok.com/) to set up a domain name, and set the `DOMAIN` variable in your `.env` file to the domain name generated by ngrok.
21-
- Unless you want to set up your local machine to support https during development, you may want to set `USE_HTTPS=false`. If you try to register your admin account and see a message that `CSRF verification failed`, you should set this option.
2221

23-
- Set up nginx for development by copying the developer nginx configuration file (`nginx/development`) into a new file named `nginx/default.conf`:
24-
``` { .sh }
25-
cp nginx/development nginx/default.conf
26-
```
22+
### Configure your environment settings
23+
24+
In `.env`:
25+
26+
4. change `DEBUG` to `true`
27+
5. If you use a tunneling/proxy service like [ngrok](https://ngrok.com), set `DOMAIN` to to the domain name you are using (e.g. `abcd-1234.ngrok-free.app`). Otherwise, set `DOMAIN` to `localhost`
28+
6. change `NGINX_SETUP` to `reverse_proxy` (this prevents BookWyrm trying to set up https certificates on your development machine)
29+
7. If you need to use a particular port (e.g. if you are tunneling via ngrok), uncomment `PORT` and set it (e.g. `PORT=1333`). If using `localhost` this is optional.
30+
31+
If you try to register your admin account and see a message that `CSRF verification failed`, you should check these settings, as you may have set your domain or port incorrectly.
32+
33+
### Email (optional)
34+
35+
If you want to test sending emails, you will need to [set up appropriate values](/environment.html#email-configuration) in the "Email config" section. You do not need to change anything for [the separate `EMAIL` setting](/environment.html#email).
36+
37+
### Build and run
38+
39+
8. In the command line, run:
2740

28-
- Start the application. In the command line, run:
2941
``` { .sh }
3042
./bw-dev build # Build the docker images
3143
./bw-dev setup # Initialize the database and run migrations. Note the ADMIN key at the end of this output. You'll need it to register the first admin user.
3244
./bw-dev up # Start the docker containers
3345
```
34-
- Once the build is complete, you can access the instance at `http://localhost:1333` and create an admin user.
46+
47+
9. Once the build is complete, you can access the instance at `http://localhost`, your ngrok domain, or `http://localhost:{PORT}`, depending on you domain and port configuration.
48+
10. You can now enter your admin key and create an admin user. From here everything is the same as described in "Running BookWyrm".
3549

3650
If you're curious: the `./bw-dev` command is a simple shell script runs various other tools: above, you could skip it and run `docker-compose build` or `docker-compose up` directly if you like. `./bw-dev` just collects them into one common place for convenience. Run it without arguments to get a list of available commands, read the [documentation page](/cli.html) for it, or open it up and look around to see exactly what each command is doing!
3751

38-
### Editing or creating Models
52+
## Editing or creating Models
3953

4054
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](https://docs.djangoproject.com/en/3.2/topics/migrations), and then `migrate` it:
4155

@@ -44,7 +58,7 @@ If you change or create a model, you will probably change the database structure
4458
./bw-dev migrate
4559
```
4660

47-
### Editing static files
61+
## Editing static files
4862
Any time you edit the CSS or JavaScript, you will need to run Django's `collectstatic` command again in order for your changes to have effect:
4963
``` { .sh }
5064
./bw-dev collectstatic

generate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,15 @@ def format_markdown(file_path):
113113
headerless.append(line)
114114
return markdown(
115115
"".join(headerless),
116-
extensions=["tables", "fenced_code", "codehilite", "toc"],
116+
extensions=["tables", "fenced_code", "codehilite", "toc", "sane_lists"],
117117
extension_configs={
118118
"codehilite": {"css_class": "highlight"},
119119
"toc": {"anchorlink": True, "anchorlink_class": "headerlink"},
120120
},
121121
)
122122
return markdown(
123123
"".join(markdown_content.readlines()[3:]),
124-
extensions=["tables", "fenced_code", "codehilite", "toc"],
124+
extensions=["tables", "fenced_code", "codehilite", "toc", "sane_lists"],
125125
extension_configs={
126126
"codehilite": {"css_class": "highlight"},
127127
"toc": {"anchorlink": True, "anchorlink_class": "headerlink"},

0 commit comments

Comments
 (0)