Skip to content

Commit 23d5b0c

Browse files
committed
feat: database setup instructions to oss deployment docs
1 parent c804e07 commit 23d5b0c

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

docs/logto-oss/deployment-and-configuration.mdx

+41
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,47 @@ You are all set. Open the browser and visit `https://admin.your-domain.com`, you
9393

9494
For production, you may use Docker to containerize Logto. You can find the Dockerfile in the root directory of the project. If you want to run multiple instances of Logto, for instance, deploy Logto in a Kubernetes cluster, There are some additional steps you need to take.
9595

96+
### Database setup \{#database-setup}
97+
98+
It is recommended to create a PostgreSQL db and user with create, update permissions. For example,
99+
100+
```sql
101+
create database logto;
102+
create user logto_admin with password <some-password> CREATEROLE;
103+
GRANT CONNECT ON DATABASE logto to logto_admin;
104+
GRANT ALL PRIVILEGES ON DATABASE logto to logto_admin;
105+
\c logto;
106+
GRANT ALL ON SCHEMA public TO logto_admin;
107+
```
108+
109+
You could then use a one-off batch job to then create the required [schemas](https://github.com/logto-io/logto/tree/master/packages/schemas),
110+
111+
```yaml
112+
apiVersion: batch/v1
113+
kind: Job
114+
metadata:
115+
name: dbSetup
116+
spec:
117+
template:
118+
spec:
119+
containers:
120+
- name: dbSetup
121+
image: svhd/logto:latest
122+
imagePullPolicy: Always
123+
env:
124+
- name: DB_URL
125+
value: postgresql://logto_admin:password@localhost:5432/logto
126+
command:
127+
- /bin/sh
128+
args:
129+
- '-c'
130+
- 'npx @logto/cli db seed --db-url $DB_URL'
131+
restartPolicy: Never
132+
```
133+
134+
Remember to specify the exact docker version instead of relying on `latest`.
135+
You could use another postgres account with limited permissions for the actual application launch but setup and alteration require more privileges.
136+
96137
### Shared connectors folder \{#shared-connectors-folder}
97138

98139
By default, Logto will create a `connectors` folder in the root directory of the `core` folder. We recommend sharing the folder between multiple instances of Logto, you need to mount the `packages/core/connectors` folder to the container and run `npm run cli connector add -- --official` to deploy the connectors.

0 commit comments

Comments
 (0)