Updated website docs and /twenty-server/.env (#8801)

Fix for the issue Incorrect Database Connection String in .env File
#8741

---------

Co-authored-by: Félix Malfait <felix@twenty.com>
This commit is contained in:
Suhotra Dey
2024-11-29 18:42:09 +05:30
committed by GitHub
parent 0136be65d1
commit 27eae53d0a
13 changed files with 25 additions and 25 deletions

View File

@ -21,7 +21,7 @@ jobs:
image: twentycrm/twenty-postgres-spilo image: twentycrm/twenty-postgres-spilo
env: env:
PGUSER_SUPERUSER: postgres PGUSER_SUPERUSER: postgres
PGPASSWORD_SUPERUSER: twenty PGPASSWORD_SUPERUSER: postgres
ALLOW_NOSSL: "true" ALLOW_NOSSL: "true"
SPILO_PROVIDER: "local" SPILO_PROVIDER: "local"
ports: ports:
@ -73,8 +73,8 @@ jobs:
- name: Server / Create DB - name: Server / Create DB
if: steps.changed-files.outputs.any_changed == 'true' if: steps.changed-files.outputs.any_changed == 'true'
run: | run: |
PGPASSWORD=twenty psql -h localhost -p 5432 -U postgres -d postgres -c 'CREATE DATABASE "default";' PGPASSWORD=postgres psql -h localhost -p 5432 -U postgres -d postgres -c 'CREATE DATABASE "default";'
PGPASSWORD=twenty psql -h localhost -p 5432 -U postgres -d postgres -c 'CREATE DATABASE "test";' PGPASSWORD=postgres psql -h localhost -p 5432 -U postgres -d postgres -c 'CREATE DATABASE "test";'
- name: Worker / Run - name: Worker / Run
if: steps.changed-files.outputs.any_changed == 'true' if: steps.changed-files.outputs.any_changed == 'true'
run: npx nx run twenty-server:worker:ci run: npx nx run twenty-server:worker:ci
@ -124,7 +124,7 @@ jobs:
image: twentycrm/twenty-postgres-spilo image: twentycrm/twenty-postgres-spilo
env: env:
PGUSER_SUPERUSER: postgres PGUSER_SUPERUSER: postgres
PGPASSWORD_SUPERUSER: twenty PGPASSWORD_SUPERUSER: postgres
ALLOW_NOSSL: "true" ALLOW_NOSSL: "true"
SPILO_PROVIDER: "local" SPILO_PROVIDER: "local"
ports: ports:

View File

@ -20,7 +20,7 @@ jobs:
image: twentycrm/twenty-postgres-spilo image: twentycrm/twenty-postgres-spilo
env: env:
PGUSER_SUPERUSER: postgres PGUSER_SUPERUSER: postgres
PGPASSWORD_SUPERUSER: twenty PGPASSWORD_SUPERUSER: postgres
ALLOW_NOSSL: "true" ALLOW_NOSSL: "true"
SPILO_PROVIDER: "local" SPILO_PROVIDER: "local"
ports: ports:
@ -46,18 +46,18 @@ jobs:
- name: Server / Create DB - name: Server / Create DB
if: steps.changed-files.outputs.any_changed == 'true' if: steps.changed-files.outputs.any_changed == 'true'
run: PGPASSWORD=twenty psql -h localhost -p 5432 -U postgres -d postgres -c 'CREATE DATABASE "default";' run: PGPASSWORD=postgres psql -h localhost -p 5432 -U postgres -d postgres -c 'CREATE DATABASE "default";'
- name: Website / Run migrations - name: Website / Run migrations
if: steps.changed-files.outputs.changed == 'true' if: steps.changed-files.outputs.changed == 'true'
run: npx nx database:migrate twenty-website run: npx nx database:migrate twenty-website
env: env:
DATABASE_PG_URL: postgres://postgres:twenty@localhost:5432/default DATABASE_PG_URL: postgres://postgres:postgres@localhost:5432/default
- name: Website / Build Website - name: Website / Build Website
if: steps.changed-files.outputs.changed == 'true' if: steps.changed-files.outputs.changed == 'true'
run: npx nx build twenty-website run: npx nx build twenty-website
env: env:
DATABASE_PG_URL: postgres://postgres:twenty@localhost:5432/default DATABASE_PG_URL: postgres://postgres:postgres@localhost:5432/default
- name: Mark as VALID - name: Mark as VALID
if: steps.changed-files.outputs.changed != 'true' # If no changes, mark as valid if: steps.changed-files.outputs.changed != 'true' # If no changes, mark as valid

View File

@ -2,17 +2,17 @@ postgres-on-docker:
docker run -d \ docker run -d \
--name twenty_pg \ --name twenty_pg \
-e PGUSER_SUPERUSER=postgres \ -e PGUSER_SUPERUSER=postgres \
-e PGPASSWORD_SUPERUSER=twenty \ -e PGPASSWORD_SUPERUSER=postgres \
-e ALLOW_NOSSL=true \ -e ALLOW_NOSSL=true \
-v twenty_db_data:/home/postgres/pgdata \ -v twenty_db_data:/home/postgres/pgdata \
-p 5432:5432 \ -p 5432:5432 \
twentycrm/twenty-postgres-spilo:latest twentycrm/twenty-postgres-spilo:latest
@echo "Waiting for PostgreSQL to be ready..." @echo "Waiting for PostgreSQL to be ready..."
@until PGPASSWORD=twenty psql -h localhost -p 5432 -U postgres -d postgres \ @until PGPASSWORD=postgres psql -h localhost -p 5432 -U postgres -d postgres \
-c 'SELECT pg_is_in_recovery();' 2>/dev/null | grep -q 'f'; do \ -c 'SELECT pg_is_in_recovery();' 2>/dev/null | grep -q 'f'; do \
sleep 1; \ sleep 1; \
done done
PGPASSWORD=twenty psql -h localhost -p 5432 -U postgres -d postgres \ PGPASSWORD=postgres psql -h localhost -p 5432 -U postgres -d postgres \
-c "CREATE DATABASE \"default\" WITH OWNER postgres;" \ -c "CREATE DATABASE \"default\" WITH OWNER postgres;" \
-c "CREATE DATABASE \"test\" WITH OWNER postgres;" -c "CREATE DATABASE \"test\" WITH OWNER postgres;"

View File

@ -22,7 +22,7 @@ services:
- "3000:3000" - "3000:3000"
environment: environment:
PORT: 3000 PORT: 3000
PG_DATABASE_URL: postgres://${PGUSER_SUPERUSER:-postgres}:${PGPASSWORD_SUPERUSER:-twenty}@${PG_DATABASE_HOST:-db:5432}/default PG_DATABASE_URL: postgres://${PGUSER_SUPERUSER:-postgres}:${PGPASSWORD_SUPERUSER:-postgres}@${PG_DATABASE_HOST:-db:5432}/default
SERVER_URL: ${SERVER_URL} SERVER_URL: ${SERVER_URL}
FRONT_BASE_URL: ${FRONT_BASE_URL:-$SERVER_URL} FRONT_BASE_URL: ${FRONT_BASE_URL:-$SERVER_URL}
REDIS_URL: ${REDIS_URL:-redis://redis:6379} REDIS_URL: ${REDIS_URL:-redis://redis:6379}
@ -52,7 +52,7 @@ services:
image: twentycrm/twenty:${TAG} image: twentycrm/twenty:${TAG}
command: ["yarn", "worker:prod"] command: ["yarn", "worker:prod"]
environment: environment:
PG_DATABASE_URL: postgres://${PGUSER_SUPERUSER:-postgres}:${PGPASSWORD_SUPERUSER:-twenty}@${PG_DATABASE_HOST:-db:5432}/default PG_DATABASE_URL: postgres://${PGUSER_SUPERUSER:-postgres}:${PGPASSWORD_SUPERUSER:-postgres}@${PG_DATABASE_HOST:-db:5432}/default
SERVER_URL: ${SERVER_URL} SERVER_URL: ${SERVER_URL}
FRONT_BASE_URL: ${FRONT_BASE_URL:-$SERVER_URL} FRONT_BASE_URL: ${FRONT_BASE_URL:-$SERVER_URL}
REDIS_URL: ${REDIS_URL:-redis://redis:6379} REDIS_URL: ${REDIS_URL:-redis://redis:6379}
@ -78,7 +78,7 @@ services:
- db-data:/home/postgres/pgdata - db-data:/home/postgres/pgdata
environment: environment:
PGUSER_SUPERUSER: ${PGUSER_SUPERUSER:-postgres} PGUSER_SUPERUSER: ${PGUSER_SUPERUSER:-postgres}
PGPASSWORD_SUPERUSER: ${PGPASSWORD_SUPERUSER:-twenty} PGPASSWORD_SUPERUSER: ${PGPASSWORD_SUPERUSER:-postgres}
ALLOW_NOSSL: "true" ALLOW_NOSSL: "true"
SPILO_PROVIDER: "local" SPILO_PROVIDER: "local"
healthcheck: healthcheck:

View File

@ -33,7 +33,7 @@ spec:
- name: PGUSER_SUPERUSER - name: PGUSER_SUPERUSER
value: "postgres" value: "postgres"
- name: PGPASSWORD_SUPERUSER - name: PGPASSWORD_SUPERUSER
value: "twenty" value: "postgres"
ports: ports:
- containerPort: 5432 - containerPort: 5432
name: tcp name: tcp

View File

@ -40,7 +40,7 @@ spec:
- name: FRONT_BASE_URL - name: FRONT_BASE_URL
value: "https://crm.example.com:443" value: "https://crm.example.com:443"
- name: "PG_DATABASE_URL" - name: "PG_DATABASE_URL"
value: "postgres://postgres:twenty@twenty-db.twentycrm.svc.cluster.local/default" value: "postgres://postgres:postgres@twenty-db.twentycrm.svc.cluster.local/default"
- name: "REDIS_URL" - name: "REDIS_URL"
value: "redis://twentycrm-redis.twentycrm.svc.cluster.local:6379" value: "redis://twentycrm-redis.twentycrm.svc.cluster.local:6379"
- name: ENABLE_DB_MIGRATIONS - name: ENABLE_DB_MIGRATIONS

View File

@ -31,7 +31,7 @@ spec:
- name: FRONT_BASE_URL - name: FRONT_BASE_URL
value: "https://crm.example.com:443" value: "https://crm.example.com:443"
- name: PG_DATABASE_URL - name: PG_DATABASE_URL
value: "postgres://postgres:twenty@twenty-db.twentycrm.svc.cluster.local/default" value: "postgres://postgres:postgres@twenty-db.twentycrm.svc.cluster.local/default"
- name: ENABLE_DB_MIGRATIONS - name: ENABLE_DB_MIGRATIONS
value: "false" # it already runs on the server value: "false" # it already runs on the server
- name: STORAGE_TYPE - name: STORAGE_TYPE

View File

@ -3,7 +3,7 @@ import path from 'path';
export const envVariables = (variables: string) => { export const envVariables = (variables: string) => {
let payload = ` let payload = `
PG_DATABASE_URL=postgres://postgres:twenty@localhost:5432/default PG_DATABASE_URL=postgres://postgres:postgres@localhost:5432/default
FRONT_BASE_URL=http://localhost:3001 FRONT_BASE_URL=http://localhost:3001
ACCESS_TOKEN_SECRET=replace_me_with_a_random_string_access ACCESS_TOKEN_SECRET=replace_me_with_a_random_string_access
LOGIN_TOKEN_SECRET=replace_me_with_a_random_string_login LOGIN_TOKEN_SECRET=replace_me_with_a_random_string_login

View File

@ -1,5 +1,5 @@
# Use this for local setup # Use this for local setup
PG_DATABASE_URL=postgres://postgres:twenty@localhost:5432/default PG_DATABASE_URL=postgres://postgres:postgres@localhost:5432/default
REDIS_URL=redis://localhost:6379 REDIS_URL=redis://localhost:6379
FRONT_BASE_URL=http://localhost:3001 FRONT_BASE_URL=http://localhost:3001

View File

@ -1,4 +1,4 @@
PG_DATABASE_URL=postgres://postgres:twenty@localhost:5432/test PG_DATABASE_URL=postgres://postgres:postgres@localhost:5432/test
REDIS_URL=redis://localhost:6379 REDIS_URL=redis://localhost:6379
DEBUG_MODE=true DEBUG_MODE=true

View File

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/sh
export PG_DATABASE_URL=postgres://postgres:twenty@$PG_DATABASE_HOST:$PG_DATABASE_PORT/default export PG_DATABASE_URL=postgres://postgres:postgres@$PG_DATABASE_HOST:$PG_DATABASE_PORT/default
yarn database:init:prod yarn database:init:prod
node dist/src/main node dist/src/main

View File

@ -1,3 +1,3 @@
#!/bin/sh #!/bin/sh
export PG_DATABASE_URL=postgres://postgres:twenty@$PG_DATABASE_HOST:$PG_DATABASE_PORT/default export PG_DATABASE_URL=postgres://postgres:postgres@$PG_DATABASE_HOST:$PG_DATABASE_PORT/default
node dist/src/queue-worker/queue-worker node dist/src/queue-worker/queue-worker

View File

@ -109,7 +109,7 @@ You should run all commands in the following steps from the root of the project.
<b>Option 1 (preferred):</b> To provision your database locally: <b>Option 1 (preferred):</b> To provision your database locally:
Use the following link to install Postgresql on your Linux machine: [Postgresql Installation](https://www.postgresql.org/download/linux/) Use the following link to install Postgresql on your Linux machine: [Postgresql Installation](https://www.postgresql.org/download/linux/)
```bash ```bash
psql postgres -c "CREATE DATABASE \"default\";" -c "CREATE DATABASE test;" -c "CREATE USER twenty PASSWORD 'twenty';" -c "ALTER ROLE twenty superuser;" psql postgres -c "CREATE DATABASE \"default\";" -c "CREATE DATABASE test;"
``` ```
Note: You might need to add `sudo -u postgres` to the command before `psql` to avoid permission errors. Note: You might need to add `sudo -u postgres` to the command before `psql` to avoid permission errors.
@ -124,7 +124,7 @@ You should run all commands in the following steps from the root of the project.
```bash ```bash
brew install postgresql@16 brew install postgresql@16
export PATH="/opt/homebrew/opt/postgresql@16/bin:$PATH" export PATH="/opt/homebrew/opt/postgresql@16/bin:$PATH"
psql postgres -c "CREATE DATABASE \"default\";" -c "CREATE DATABASE test;" -c "CREATE USER twenty PASSWORD 'twenty';" -c "ALTER ROLE twenty superuser;" psql postgres -c "CREATE DATABASE \"default\";" -c "CREATE DATABASE test;"
``` ```
<b>Option 2:</b> If you have docker installed: <b>Option 2:</b> If you have docker installed:
@ -138,7 +138,7 @@ You should run all commands in the following steps from the root of the project.
<b>Option 1:</b> To provision your Postgresql locally: <b>Option 1:</b> To provision your Postgresql locally:
Use the following link to install Postgresql on your Linux virtual machine: [Postgresql Installation](https://www.postgresql.org/download/linux/) Use the following link to install Postgresql on your Linux virtual machine: [Postgresql Installation](https://www.postgresql.org/download/linux/)
```bash ```bash
psql postgres -c "CREATE DATABASE \"default\";" -c "CREATE DATABASE test;" -c "CREATE USER twenty PASSWORD 'twenty';" -c "ALTER ROLE twenty superuser;" psql postgres -c "CREATE DATABASE \"default\";" -c "CREATE DATABASE test;"
``` ```
Note: You might need to add `sudo -u postgres` to the command before `psql` to avoid permission errors. Note: You might need to add `sudo -u postgres` to the command before `psql` to avoid permission errors.