Skip to content

Commit

Permalink
Clean up setup
Browse files Browse the repository at this point in the history
  • Loading branch information
ArendPeter committed Jan 29, 2025
1 parent de1a06b commit ac30844
Showing 1 changed file with 25 additions and 20 deletions.
45 changes: 25 additions & 20 deletions docs/contributions/1_local_setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,48 +270,53 @@ f443236f9609 postgres "docker-entrypoint.s…" 5 d

Also the Keycloak UI should be running at http://localhost:8080/

#### Migrating database

Your database is running, but all the tables still need to be created. The following steps will ensure all the table are properly initialized.

```bash
npm run build -w @equal-vote/star-vote-backend
npm run migrate:latest -w @equal-vote/star-vote-backend
```

**Verification Steps**

You should see a series of migration success messages

```
migration "2023_07_03_Initial" was executed successfully
migration "2024_01_27_Create_Date" was executed successfully
migration "2024_01_29_pkeys_and_heads" was executed successfully
```

#### Configuring Keycloak

We need to manually configure keycloak, and set some .env variables so that it can interface with the service properly.

*First we need to set the configuration*
1. [Download the Keycloak configuration](https://drive.google.com/file/d/1_S-MpnsxSr8oeA6MrNd3VSOGyKe7Qca_/view?usp=sharing), and select that for your Resource file
1. Navigate to localhost:8080 , select Administration Console
1. Login with user=admin, password=admin
1. Select the master dropdown in the top-left, select "Create Realm"
1. Name it "Dev" and click "Create"
1. Select Realm Settings on the left Nav, then open the Action dropdown in the top-right and select "Partial import"
1. [Download the Keycloak configuration](https://drive.google.com/file/d/1_S-MpnsxSr8oeA6MrNd3VSOGyKe7Qca_/view?usp=sharing), and select that for your Resource file
1. ✅ clients, ✅ identity providers, already_exists_policy=Skip, then click import
1. Browse to select the configuration you downloaded
1. Click "Create"

*Setting KEYCLOAK_SECRET*
1. Within the Keycloak UI, select clients in the left panel
1. Select web, then the Credentials tab
1. Click "Regenerate" next to the Client Secret
1. Copy the secret and paste it for KEYCLOAK_SECRET within .env
1. Copy the secret and paste it for KEYCLOAK_SECRET within packages/backend/.env

*Setting KEYCLOAK_PUBLIC_KEY*
1. Navigate to http://localhost:8080/realms/Dev
1. Copy the public_key portion of the JSON
1. Paste to your .env under KEYCLOAK_PUBLIC_KEY
1. Paste to your packages/backend/.env under KEYCLOAK_PUBLIC_KEY

**Verification Steps**
Now you should be able to register with a username and password via your frontend at localhost:3000
It's tricky to verify at the moment, but once you have the backend running you should be able to register with a username and password via your frontend at localhost:3000.

NOTE: login with google won't work yet

#### Migrating database

Your database is running, but all the tables still need to be created. The following steps will ensure all the table are properly initialized.

```bash
npm run build -w @equal-vote/star-vote-backend
npm run migrate:latest -w @equal-vote/star-vote-backend
```

**Verification Steps**

TODO

### Backend : Run the backend

Running your own backend is optional, if you only plan to work in the frontend then you can setup your .env to reference the live backend instead of running your own .
Expand Down

0 comments on commit ac30844

Please sign in to comment.