From ac308447fdd67d67107a9bb04594c58c0e81053a Mon Sep 17 00:00:00 2001 From: Arend Peter Date: Wed, 29 Jan 2025 00:13:52 -0800 Subject: [PATCH] Clean up setup --- docs/contributions/1_local_setup.md | 45 ++++++++++++++++------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/docs/contributions/1_local_setup.md b/docs/contributions/1_local_setup.md index 3e5bd3e7..6d104d8d 100644 --- a/docs/contributions/1_local_setup.md +++ b/docs/contributions/1_local_setup.md @@ -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 .