develop against local zitadel

This commit is contained in:
Elio Bischof
2024-10-17 16:42:49 +02:00
parent cb8f071729
commit 1134b9c4b1
6 changed files with 43 additions and 22 deletions

View File

@@ -175,32 +175,56 @@ To run the application make sure to install the dependencies with
pnpm install
```
then setup the environment for the login application which needs a `.env.local` in `/apps/login`.
Go to your instance and create a service user for the application having the `IAM_OWNER` manager role.
This user is required to have access to create users on your primary organization and reading policy data so it can be
restricted to your personal use case but we'll stick with `IAM_OWNER` for convenience. Create a PAT and copy the value to
paste it under the `ZITADEL_SERVICE_USER_TOKEN` key.
The file should look as follows:
```
ZITADEL_API_URL=[yourinstanceurl]
ZITADEL_ORG_ID=[yourprimaryorg]
ZITADEL_SERVICE_USER_TOKEN=[yourserviceuserpersonalaccesstoken]
```
then generate the GRPC stubs with
```sh
pnpm generate
```
and then run it with
To run the application against a local ZITADEL instance, run the following command:
```sh
pnpm run-zitadel
```
This sets up ZITADEL using docker compose and writes the configuration to the file `apps/login/.env.local`.
<details>
<summary>Alternatively, use another environment</summary>
You can develop against any ZITADEL instance in which you have sufficient rights to execute the following steps.
Just create or overwrite the file `apps/login/.env.local` yourself.
Add your instances base URL to the file at the key `ZITADEL_API_URL`.
Go to your instance and create a service user for the login application.
The login application creates users on your primary organization and reads policy data.
For the sake of simplicity, just make the service user an instance member with the role `IAM_OWNER`.
Create a PAT and copy it to the file `apps/login/.env.local` using the key `ZITADEL_SERVICE_USER_TOKEN`.
Also add the users ID to the file using the key `ZITADEL_SERVICE_USER_ID`.
The file should look similar to this:
```
ZITADEL_API_URL=https://zitadel-tlx3du.us1.zitadel.cloud
ZITADEL_SERVICE_USER_ID=289106423158521850
ZITADEL_SERVICE_USER_TOKEN=1S6w48thfWFI2klgfwkCnhXJLf9FQ457E-_3H74ePQxfO3Af0Tm4V5Xi-ji7urIl_xbn-Rk
```
</details>
Start the login application in dev mode:
```sh
pnpm dev
```
Open the login application with your favorite browser at `localhost:3000`.
Change the source code and see the changes live in your browser.
Make sure the application still behaves as expected by running all tests
```sh
pnpm test
```
To satisfy your unique workflow requirements, check out the package.json in the root directory for more detailed scripts.
### Deploy to Vercel

View File

@@ -1 +1 @@
zitadel-admin-sa.json
*

View File

@@ -1 +0,0 @@
fEJWwOJ3lFAn-COq0QxdXz_xCGrmp8Kj2l4i-xGWbh1UM2OtNwNz3_MblwOf_Lsd13B8ORk

View File

@@ -6,7 +6,7 @@ FirstInstance:
FirstName: ZITADEL
LastName: Admin
Password: Password1!
PasswordChangeRequired: true
PasswordChangeRequired: false
PreferredLanguage: en
Machine:
Machine:
@@ -39,7 +39,3 @@ Logstore:
Access:
Stdout:
Enabled: true
DefaultInstance:
LoginPolicy:
MfaInitSkipLifetime: 0h

View File

@@ -9,6 +9,7 @@
"start": "turbo run start",
"test:unit": "turbo run test:unit -- --passWithNoTests",
"test:integration": "turbo run test:integration",
"test:acceptance": "pnpm exec playwright test",
"test:watch": "turbo run test:watch",
"dev": "turbo run dev --no-cache --continue",
"lint": "turbo run lint",
@@ -17,7 +18,8 @@
"format": "prettier --check \"**/*.{ts,tsx,md}\"",
"changeset": "changeset",
"version-packages": "changeset version",
"release": "turbo run build --filter=login^... && changeset publish"
"release": "turbo run build --filter=login^... && changeset publish",
"run-zitadel": "docker compose -f ./acceptance/docker-compose.yaml run setup"
},
"pnpm": {
"overrides": {