|
2 | 2 |
|
3 | 3 | CLI tool to setup and manage document box instances |
4 | 4 |
|
5 | | -# Create credentials file |
| 5 | +## Create credentials file |
6 | 6 |
|
7 | | -The credentials file is used by the CLI to access the database with a higher level of permissions to perform things like migrations and setting up tenants. You will need this to perform a majority of the CLI actions: |
| 7 | +The CLI tool require a configuration file in order to operate. See the [CLI Config](https://docbox-nz.pages.dev/docs/guides/setup/cli-config) guide to set one up |
8 | 8 |
|
| 9 | +## Initialize root database |
9 | 10 |
|
10 | | -Create a file name `cli-credentials.json` in the root of the repository: |
| 11 | +Before you can setup docbox tenants you must setup the root docbox database. See the [Create Root](https://docbox-nz.pages.dev/docs/guides/setup/create-root) guide to set this up |
11 | 12 |
|
12 | | -```json |
13 | | -{ |
14 | | - "database": { |
15 | | - "__description": "Database details and credentials", |
16 | | - "host": "{DATABASE HOST}", |
17 | | - "port": 5432, // DATABASE PORT |
18 | | - "root_secret_name": "{ROOT DATABASE SECRET NAME}", |
19 | | - "root_role_name": "{ROOT DATABASE ROLE NAME}", |
20 | | - "root_secret_password": "{ROOT DATABASE SECRET PASSWORD}", |
21 | | - "setup_user": { |
22 | | - "__description": "User to use when migrating and setting up database, should have higher permissions", |
23 | | - "username": "{DB USER}", |
24 | | - "password": "{DB PASSWORD}" |
25 | | - } |
26 | | - }, |
27 | | - "secrets": { |
28 | | - "__description": "Secrets manager configurations", |
29 | | - "provider": "aws" |
30 | | - }, |
31 | | - "search": { |
32 | | - "__description": "Search index factory configuration", |
33 | | - "provider": "typesense", |
34 | | - "url": "http://localhost:8108", |
35 | | - "api_key": "typesensedev" |
36 | | - }, |
37 | | - "storage": { |
38 | | - "provider": "s3", |
39 | | - "endpoint": { |
40 | | - "type": "aws" |
41 | | - } |
42 | | - } |
43 | | -} |
44 | | -``` |
| 13 | +## Create new tenant |
45 | 14 |
|
46 | | -# Initialize root database |
47 | | - |
48 | | -To initialize the root database for docbox run the following command |
49 | | - |
50 | | -```sh |
51 | | -cargo run --release -p docbox-cli -- create-root |
52 | | -``` |
53 | | - |
54 | | -# Create new tenant |
55 | | - |
56 | | -Create a new file in this case `demo-tenant.json` this will contain the following: |
57 | | - |
58 | | -```json |
59 | | -{ |
60 | | - "id": "00000000-0000-0000-0000-000000000000", |
61 | | - "env": "{Development/Production}", |
62 | | - "db_name": "docbox-{tag}-{dev/prod}", |
63 | | - "db_secret_name": "postgres/docbox/{dev/prod}/{tag}", |
64 | | - "db_role_name": "{TENANT DB ROLE NAME}", |
65 | | - "storage_bucket_name": "docbox-{tag}-{dev/prod}", |
66 | | - "search_index_name": "docbox-{tag}-{dev/prod}", |
67 | | - "storage_s3_queue_arn": "arn:aws:sqs:ap-southeast-2:{YOUR_S3_UPLOADS_QUEUE_ARN}", |
68 | | - "event_queue_url": "https://sqs.ap-southeast-2.amazonaws.com/{YOUR_EVENT_QUEUE_ARN}", |
69 | | - "storage_cors_origins": [ |
70 | | - "https://{SOME_ORIGIN}" |
71 | | - ] |
72 | | -} |
73 | | -``` |
74 | | - |
75 | | -Then run the following command from the root of this repository: |
76 | | - |
77 | | -> You must ensure you have a `.env` file setup containing all the required environment |
78 | | -> variables from the terraform setup |
79 | | -> |
80 | | -> Along with: |
81 | | -> ``` |
82 | | -> AWS_ACCESS_KEY_ID={YOUR AWS KEY ID} |
83 | | -> AWS_SECRET_ACCESS_KEY={YOUR AWS SECRET ACCESS KEY} |
84 | | -> ``` |
85 | | -> |
86 | | -> The specified key must have high enough permission to manage S3 buckets |
87 | | -
|
88 | | -
|
89 | | -```sh |
90 | | -cargo run --release -p docbox-cli -- create-tenant --file ./demo-tenant.json |
91 | | -``` |
| 15 | +To create a new tenant with the CLI follow the [Create Tenant](https://docbox-nz.pages.dev/docs/guides/setup/create-tenant) guide. |
92 | 16 |
|
93 | 17 | # Migrations |
94 | 18 |
|
|
0 commit comments