You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/dev_setup.md
+12-7Lines changed: 12 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,17 +14,18 @@ You will need the following:
14
14
15
15
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`.
16
16
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.
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?
24
25
25
26
You can stop and start your container using `docker stop geode-db`, and `docker start geode-db`, respectively
26
27
27
-
## 2. Running migrations
28
+
## 2. Environment file
28
29
29
30
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
30
31
```bash
@@ -36,22 +37,26 @@ The first thing that is recommended is setting `APP_DEBUG` to `1` if you are run
36
37
37
38
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`.
38
39
40
+
Finally, run your migrations from the project directory using `sqlx migrate run`
41
+
42
+
## 3. GitHub authentication (optional)
43
+
39
44
> [!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**.
41
46
42
47
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.
43
48
44
-
Finally, run your migrations from the project directory using `sqlx migrate run`
49
+
## 4. Logging
45
50
46
51
Next up, set up the log4rs config file found in `config`:
47
52
```bash
48
53
cp config/log4rs.example.yaml config/log4rs.yaml
49
54
```
50
55
Feel free to change the settings, but the default works fine.
51
56
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.
53
58
54
-
## 3. Admin users
59
+
## 5. Admin users
55
60
56
61
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:
0 commit comments