Skip to content

Commit acda7ac

Browse files
committed
docs: update dev_setup.md
1 parent b22b790 commit acda7ac

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

docs/dev_setup.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,18 @@ You will need the following:
1414

1515
First step after installing all the required tools is setting up your database. If you have installed PostgreSQL locally, you have to setup a new database for the index, alongside a new user. For the purposes of this guide, the database, user and password will all be `geode`.
1616

17-
If you want to run PostgreSQL with Docker, first install Docker for your platform, then you can use the following command in your terminal of choice to run a PostgreSQL container.
17+
If you want to run **PostgreSQL with Docker**, first install Docker for your platform, then you can use the following commands in your terminal of choice to run a PostgreSQL container.
1818

1919
```bash
20-
docker run -p 5432:5432 --name=geode-db -v postgres:/var/lib/postgresql/data --restart=unless-stopped -e POSTGRES_DB=geode -e POSTGRES_USER=geode -e POSTGRES_PASSWORD=geode -dit postgres:14-alpine3.20
20+
docker volume create geode-pgsql
21+
docker run -p 5432:5432 --name=geode-db -v geode-pgsql:/var/lib/postgresql/data --restart=unless-stopped -e POSTGRES_DB=geode -e POSTGRES_USER=geode -e POSTGRES_PASSWORD=geode -dit postgres:14-alpine3.21
2122
```
2223

2324
This creates a lightweight container (using Alpine Linux) that contains your database. It exposes the port `5432`, so you can connect to it from outside the container itself. Note that you can change this if you already use `5432` on your machine, just change the first part of the port binding (for example, if I were to use `5433`, my port binding would become `5433:5432`). It also creates a **named volume**, so that the data you enter will be stored between container restarts. The environment variables passed to the container initialize a new database, called `geode`, owned by a new user, called `geode`, with the password `geode`. Easy, right?
2425

2526
You can stop and start your container using `docker stop geode-db`, and `docker start geode-db`, respectively
2627

27-
## 2. Running migrations
28+
## 2. Environment file
2829

2930
Once you have your database setup, we can start configuring the **environment file** of the index. Open a terminal inside your index directory, and run
3031
```bash
@@ -36,22 +37,26 @@ The first thing that is recommended is setting `APP_DEBUG` to `1` if you are run
3637

3738
The second step is setting our `DATABASE_URL`. It has a specific structure: `postgres://{username}:{password}@{db_host}/{database}`. In our case, after completing it with our data, the URL becomes: `postgres://geode:geode@localhost/geode`.
3839

40+
Finally, run your migrations from the project directory using `sqlx migrate run`
41+
42+
## 3. GitHub authentication (optional)
43+
3944
> [!TIP]
40-
> You can get away with setting this up by manually adding developers to the database. Just add rows to `developers` and `auth_tokens` manually, while keeping in mind tokens in the database are sha256'd uuid tokens.
45+
> You can get away with setting this up by manually adding developers to the database. Just add rows to `developers` and `auth_tokens` manually, while keeping in mind tokens in the database are **sha256'd uuid tokens**.
4146
4247
Third, we need to setup a local GitHub OAuth app. Since the index doesn't store passwords, and uses GitHub for logins, we need this step to login into the index. Check out this guide for [creating a GitHub OAuth app](https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/creating-an-oauth-app), then fill in the client ID and secret of your app inside the .env file.
4348

44-
Finally, run your migrations from the project directory using `sqlx migrate run`
49+
## 4. Logging
4550

4651
Next up, set up the log4rs config file found in `config`:
4752
```bash
4853
cp config/log4rs.example.yaml config/log4rs.yaml
4954
```
5055
Feel free to change the settings, but the default works fine.
5156

52-
After all of this is done, you should be able to run `cargo run` inside the index directory. The migrations will be ran automatically, and the index will start. You can check `http://localhost:8000` (if you haven't changed the app port) to see if it all works.
57+
After all of this is done, you should be able to run `cargo run` inside the index directory. The migrations will be ran automatically, and the index will start. You can check `http://localhost:8080` (if you haven't changed the port in your .env file) to see if it all works.
5358

54-
## 3. Admin users
59+
## 5. Admin users
5560

5661
At the moment, there is no easy way to make yourself an admin, other than editing the database itself. A small script to automate this will be created in the future. For now, you can run this simple SQL query:
5762

0 commit comments

Comments
 (0)