Chore tooljetdb env (#5267)

* Update digitalocean.md

* Update heroku.md

* Update google-cloud-run.md

* Update docker.md

* Update kubernetes-aks.md

* Update kubernetes-gke.md

* Update ecs.md

* Update google-cloud-run.md

* Add tooljetdb env vars for separate instance (#5273)

* Update try tj docker file for tjdb env vars (#5274)

Co-authored-by: Akshay <akshaysasidharan93@gmail.com>
This commit is contained in:
Adish M 2023-01-09 20:35:24 +05:30 committed by GitHub
parent 6131c25bea
commit 1ebc8b877d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 46 additions and 86 deletions

View file

@ -17,7 +17,11 @@ PG_HOST=<db host>
PG_PASS=<db password>
# TOOLJET DATABASE
ENABLE_TOOLJET_DB=
TOOLJET_DB=
TOOLJET_DB_USER=
TOOLJET_DB_HOST=
TOOLJET_DB_PASS=
PGRST_HOST=
PGRST_JWT_SECRET=

View file

@ -34,15 +34,18 @@ ENV TOOLJET_HOST=http://localhost \
PORT=80 \
LOCKBOX_MASTER_KEY=replace_with_lockbox_master_key \
SECRET_KEY_BASE=replace_with_secret_key_base \
TOOLJET_DB=tooljet_db \
ENABLE_TOOLJET_DB=true \
PGRST_HOST=http://localhost:3000 \
PGRST_DB_URI=postgres://tooljet:postgres@localhost/tooljet_db \
PGRST_JWT_SECRET=r9iMKoe5CRMgvJBBtp4HrqN7QiPpUToj \
PG_DB=tooljet_production \
PG_USER=tooljet \
PG_PASS=postgres \
PG_HOST=localhost \
ENABLE_TOOLJET_DB=true \
TOOLJET_DB_HOST=localhost \
TOOLJET_DB_USER=postgres \
TOOLJET_DB_PASS=postgres \
TOOLJET_DB=tooljet_db \
PGRST_HOST=http://localhost:3000 \
PGRST_DB_URI=postgres://tooljet:postgres@localhost/tooljet_db \
PGRST_JWT_SECRET=r9iMKoe5CRMgvJBBtp4HrqN7QiPpUToj \
ORM_LOGGING=true \
DEPLOYMENT_PLATFORM=docker:local \
TERM=xterm

View file

@ -49,7 +49,7 @@ You can learn more about this feature [here](/docs/tooljet-database).
Follow the steps below to deploy ToolJet Database on DigitalOcean:
1. If you are using dev database within ToolJet deployment, upgrade it to managed database.
1. If you are using dev database within ToolJet deployment, upgrade it to managed database. You could also add a separate database, if you intent use a differenet database, please refer the [environment variables](/docs/setup/env-vars#tooljet-database-feature-enable--optional-) for additional env variables.
2. Create a new app for PostgREST server. You can opt for docker hub to deploy PostgREST image of version `10.1.x`.
@ -59,6 +59,6 @@ Follow the steps below to deploy ToolJet Database on DigitalOcean:
<img className="screenshot-full" src="/img/setup/digitalocean/postgrest-env.png" alt="ToolJet - Deploy on DigitalOcean - PostgREST environment variables" />
4. Add your newly created PostgREST app to the trusted sources of your managed database.
4. Add your newly created PostgREST app to the trusted sources of your managed or separate database.
5. Update your existing ToolJet application deployment with [environment variables](/docs/setup/env-vars#tooljet-database-feature-enable--optional-) required for PostgREST.
5. Update your existing ToolJet application deployment with [environment variables](/docs/setup/env-vars#tooljet-database-feature-enable--optional-) required for PostgREST.

View file

@ -147,25 +147,3 @@ If you'd want to run postgres with persistent volume rather, curl for the altern
</TabItem>
</Tabs>
### Creating admin workspace and account
```bash
docker-compose exec server npm run db:seed:prod
```
This seeds the database with a default user with the following credentials:
- email: `dev@tooljet.io`
- password: `password`
:::caution
Make sure that the server can receive traffic on port 80 & 443.
For example, if the server is an AWS EC2 instance and the installation should receive traffic from the internet, the inbound rules of the security group should look like this:
| protocol | port | allowed_cidr |
| -------- | ---- | ------------ |
| TCP | 80 | 0.0.0.0/0 |
| TCP | 443 | 0.0.0.0/0 |
:::
You're all done! ToolJet would now be served at the URL you've set in `TOOLJET_HOST`.

View file

@ -75,20 +75,3 @@ Follow the steps below to deploy ToolJet on a ECS cluster.
The setup above is just a template. Feel free to update the task definition and configure parameters for resources and environment variables according to your needs.
:::
5. Verify if ToolJet is running by checking by checking the status of the tasks in the created service.
### Creating default admin workspace and account
You can create a new revision of your existing task definition to have a one time task to seed with default admin.
1. Create a new revision from your existing task definition.
You can change task definition name to `tooljet-seed-task`
2. Click on your existing container name to edit container.
3. Change container command from `npm,run,start:prod` to `npm,run,db:seed:prod`
4. Go back to your cluster dashboard and click on Run new task.
<img className="screenshot-full" src="/img/setup/ecs/run-new-task.png" alt="run new task" />
5. Configure your run task with the `tooljet-seed-task` for your cluster. It should look like:
<img className="screenshot-full" src="/img/setup/ecs/run-task-config.png" alt="run task config" />
6. Click on run task to have this task seed the database with user having following credentials:
- email: `dev@tooljet.io`
- password: `password`

View file

@ -124,22 +124,16 @@ If you intend to use this feature, you'd have to set up and deploy PostgREST ser
<div style={{textAlign: 'center'}}>
<img className="screenshot-full" src="/img/cloud-run/port-and-capacity-postgrest.png" alt="port-and-capacity-postgrest" />
</div>
5. Under environmental variable please add correponding Tooljet database env variables. You can also refer [env variable](/docs/setup/env-vars#tooljet-database).
5. Under environmental variable please add the below PostgREST variables. You can also refer env variable [**here**](/docs/setup/env-vars#tooljet-database)
<div style={{textAlign: 'center'}}>
<img className="screenshot-full" src="/img/cloud-run/env-variables-postgrest.png" alt="env-variables-postgrest" />
</div>
6. Please go to the connection tab. Under Cloud SQL instance please select the PostgreSQL database which you have set-up for Tooljet application.
6. Please go to connection tab. Under Cloud SQL instance please select the PostgreSQL database which you have set-up for Tooljet application or the separate PostgreSQL database created respective to Tooljet Database from the drop-down option.
<div style={{textAlign: 'center'}}>
<img className="screenshot-full" src="/img/cloud-run/Cloud-SQL-instance.png" alt="Cloud-SQL-instance" />
</div>
Click on deploy once the above parameters are set.

View file

@ -140,8 +140,3 @@ Please install Heroku CLI on your local machine. Please refer Heroku CLI install
Please enter the below env variables in the Tooljet application, under the setting tab. You can also refer environment variable [**here**](/docs/setup/env-vars#tooljet-database).
<div style={{textAlign: 'center'}}>
<img className="screenshot-full" src="/img/heroku/evn-tooljet-app.png" alt="evn-tooljet-app" />
</div>

View file

@ -38,15 +38,7 @@ If there are self signed HTTPS endpoints that Tooljet needs to connect to, pleas
You will be able to access your ToolJet installation once the pods and services running.
If you want to seed the database with a sample user, please SSH into a pod and run:
`npm run db:seed:prod --prefix server`
This seeds the database with a default user with the following credentials:
**email**: `dev@tooljet.io`
**password**: `password`
## ToolJet Database

View file

@ -63,15 +63,7 @@ It might take a few minutes to provision the managed certificates. [Managed cert
You will be able to access your ToolJet installation once the pods, service and the ingress is running.
If you want to seed the database with a sample user, please SSH into a pod and run:
`npm run db:seed:prod --prefix server`
This seeds the database with a default user with the following credentials:
**emai**: `dev@tooljet.io`
**password**: `password`
## ToolJet Database

View file

@ -58,10 +58,10 @@ function buildConnectionOptions(data): TypeOrmModuleOptions {
function buildToolJetDbConnectionOptions(data): TypeOrmModuleOptions {
const connectionParams = {
database: data.TOOLJET_DB,
port: +data.PG_PORT || 5432,
username: data.PG_USER,
password: data.PG_PASS,
host: data.PG_HOST,
port: +data.TOOLJET_DB_PORT || 5432,
username: data.TOOLJET_DB_USER,
password: data.TOOLJET_DB_PASS,
host: data.TOOLJET_DB_HOST,
connectTimeoutMS: 5000,
extra: {
max: 25,

View file

@ -25,6 +25,7 @@ export function getEnvVars() {
...data,
...(data.DATABASE_URL && buildDbConfigFromDatabaseURL(data)),
};
return data;
}
@ -51,8 +52,14 @@ function buildDbConfigFromDatabaseURL(data): any {
PG_PASS: config.password,
PG_USER: config.user,
PG_DB: config.database,
TOOLJET_DB: data?.TOOLJET_DB,
PG_DB_OWNER: data?.PG_DB_OWNER,
PG_DB_OWNER: data.PG_DB_OWNER,
ENABLE_TOOLJET_DB: data.ENABLE_TOOLJET_DB,
TOOLJET_DB: data.TOOLJET_DB,
TOOLJET_DB_OWNER: data.TOOLJET_DB_OWNER,
TOOLJET_DB_HOST: config.host,
TOOLJET_DB_PORT: config.port,
TOOLJET_DB_PASS: config.password,
TOOLJET_DB_USER: config.user,
});
if (error) {
@ -76,8 +83,15 @@ function validateDatabaseConfig(dbConfig: any): Joi.ValidationResult {
PG_PASS: Joi.string().default(''),
PG_USER: Joi.string().required(),
PG_DB: Joi.string().default('tooljet_production'),
TOOLJET_DB: Joi.string().default('tooljet_db'),
PG_DB_OWNER: Joi.string().default('true'),
...(dbConfig.ENABLE_TOOLJET_DB === 'true' && {
TOOLJET_DB_HOST: Joi.string().default('localhost'),
TOOLJET_DB_PORT: Joi.number().positive().default(5432),
TOOLJET_DB_PASS: Joi.string().default(''),
TOOLJET_DB_USER: Joi.string().required(),
TOOLJET_DB: Joi.string().default('tooljet_db'),
TOOLJET_DB_OWNER: Joi.string().default('true'),
}),
})
.unknown();
@ -92,8 +106,13 @@ export function buildAndValidateDatabaseConfig(): Joi.ValidationResult {
PG_PASS: config.PG_PASS,
PG_USER: config.PG_USER,
PG_DB: config.PG_DB,
TOOLJET_DB: config.TOOLJET_DB,
PG_DB_OWNER: config.PG_DB_OWNER,
TOOLJET_DB: config.TOOLJET_DB,
TOOLJET_DB_HOST: config.TOOLJET_DB_HOST,
TOOLJET_DB_PORT: config.TOOLJET_DB_PORT,
TOOLJET_DB_PASS: config.TOOLJET_DB_PASS,
TOOLJET_DB_USER: config.TOOLJET_DB_USER,
TOOLJET_DB_OWNER: config.TOOLJET_DB_OWNER,
};
return validateDatabaseConfig(dbConfig);