From e2f83f3ec695bfb06135b466409cc0edf19d926f Mon Sep 17 00:00:00 2001 From: john-s4d Date: Tue, 21 Jan 2025 14:23:00 -0500 Subject: [PATCH 1/8] improve docker-compose install doc --- packages/twenty-docker/.env.example | 4 ++-- .../src/content/developers/self-hosting/docker-compose.mdx | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/twenty-docker/.env.example b/packages/twenty-docker/.env.example index 591e4c91be11..bb9c003260bd 100644 --- a/packages/twenty-docker/.env.example +++ b/packages/twenty-docker/.env.example @@ -1,8 +1,8 @@ TAG=latest #PGUSER_SUPERUSER=postgres -#PGPASSWORD_SUPERUSER=replace_me_with_a_strong_password -#PG_DATABASE_HOST=db +#PGPASSWORD_SUPERUSER=replace_me_with_a_url-safe_strong_password +#PG_DATABASE_HOST=db:5432 #REDIS_URL=redis://redis:6379 SERVER_URL=http://localhost:3000 diff --git a/packages/twenty-website/src/content/developers/self-hosting/docker-compose.mdx b/packages/twenty-website/src/content/developers/self-hosting/docker-compose.mdx index fa2f2bc63d17..20b2f59212c8 100644 --- a/packages/twenty-website/src/content/developers/self-hosting/docker-compose.mdx +++ b/packages/twenty-website/src/content/developers/self-hosting/docker-compose.mdx @@ -44,7 +44,7 @@ Follow these steps for a manual setup. Copy the example environment file to a new .env file in your working directory: ```bash - curl -o .env https://raw.githubusercontent.com/twentyhq/twenty/refs/tags/v0.35.0/packages/twenty-docker/.env.example + curl -o .env https://raw.githubusercontent.com/twentyhq/twenty/refs/heads/main/packages/twenty-docker/.env.example ``` 2. **Generate Secret Tokens** @@ -65,7 +65,7 @@ Follow these steps for a manual setup. 4. **Set the Postgres Password** - Update the `PGPASSWORD_SUPERUSER` value in the .env file with a strong password. + Update the `PGPASSWORD_SUPERUSER` value in the .env file with a strong password that is URL-safe or properly URL-encoded. ```ini PGPASSWORD_SUPERUSER=my_strong_password @@ -76,7 +76,7 @@ Follow these steps for a manual setup. Download the `docker-compose.yml` file to your working directory: ```bash -curl -O https://raw.githubusercontent.com/twentyhq/twenty/refs/tags/v0.35.0/packages/twenty-docker/docker-compose.yml +curl -o docker-compose.yml https://raw.githubusercontent.com/twentyhq/twenty/refs/heads/main/packages/twenty-docker/docker-compose.yml ``` ### Step 3: Launch the Application From b16065b34b3f68eb885c1191f98a80d150432a71 Mon Sep 17 00:00:00 2001 From: john-s4d Date: Tue, 21 Jan 2025 15:34:57 -0500 Subject: [PATCH 2/8] handling PG_DATABASE_URL better in docker-compose --- packages/twenty-docker/docker-compose.yml | 4 ++-- .../src/content/developers/self-hosting/docker-compose.mdx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/twenty-docker/docker-compose.yml b/packages/twenty-docker/docker-compose.yml index df3293cbfc40..fe0db85ff38a 100644 --- a/packages/twenty-docker/docker-compose.yml +++ b/packages/twenty-docker/docker-compose.yml @@ -21,7 +21,7 @@ services: - "3000:3000" environment: PORT: 3000 - PG_DATABASE_URL: postgres://${PGUSER_SUPERUSER:-postgres}:${PGPASSWORD_SUPERUSER:-postgres}@${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} REDIS_URL: ${REDIS_URL:-redis://redis:6379} @@ -47,7 +47,7 @@ services: image: twentycrm/twenty:${TAG:-latest} command: ["yarn", "worker:prod"] environment: - PG_DATABASE_URL: postgres://${PGUSER_SUPERUSER:-postgres}:${PGPASSWORD_SUPERUSER:-postgres}@${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} REDIS_URL: ${REDIS_URL:-redis://redis:6379} DISABLE_DB_MIGRATIONS: "true" # it already runs on the server diff --git a/packages/twenty-website/src/content/developers/self-hosting/docker-compose.mdx b/packages/twenty-website/src/content/developers/self-hosting/docker-compose.mdx index 20b2f59212c8..ed1a0780e657 100644 --- a/packages/twenty-website/src/content/developers/self-hosting/docker-compose.mdx +++ b/packages/twenty-website/src/content/developers/self-hosting/docker-compose.mdx @@ -65,7 +65,7 @@ Follow these steps for a manual setup. 4. **Set the Postgres Password** - Update the `PGPASSWORD_SUPERUSER` value in the .env file with a strong password that is URL-safe or properly URL-encoded. + Update the `PGPASSWORD_SUPERUSER` value in the .env file with a strong password that is URL-safe. ```ini PGPASSWORD_SUPERUSER=my_strong_password From 4884d3bbc4adf9ea9ea57868cab6d2e235b3c3ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Malfait?= Date: Wed, 22 Jan 2025 10:32:27 +0100 Subject: [PATCH 3/8] Address review comments --- packages/twenty-docker/.env.example | 2 +- packages/twenty-docker/docker-compose.yml | 2 +- packages/twenty-docker/scripts/install.sh | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/twenty-docker/.env.example b/packages/twenty-docker/.env.example index bb9c003260bd..993e68257ee0 100644 --- a/packages/twenty-docker/.env.example +++ b/packages/twenty-docker/.env.example @@ -2,7 +2,7 @@ TAG=latest #PGUSER_SUPERUSER=postgres #PGPASSWORD_SUPERUSER=replace_me_with_a_url-safe_strong_password -#PG_DATABASE_HOST=db:5432 +#PG_DATABASE_HOST=db #REDIS_URL=redis://redis:6379 SERVER_URL=http://localhost:3000 diff --git a/packages/twenty-docker/docker-compose.yml b/packages/twenty-docker/docker-compose.yml index fe0db85ff38a..c8978564e31c 100644 --- a/packages/twenty-docker/docker-compose.yml +++ b/packages/twenty-docker/docker-compose.yml @@ -21,7 +21,7 @@ services: - "3000:3000" environment: PORT: 3000 - PG_DATABASE_URL: "postgres://${PGUSER_SUPERUSER:-postgres}:${PGPASSWORD_SUPERUSER:-postgres}@${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} REDIS_URL: ${REDIS_URL:-redis://redis:6379} diff --git a/packages/twenty-docker/scripts/install.sh b/packages/twenty-docker/scripts/install.sh index 5d560d6c773c..1fcb65c99b02 100755 --- a/packages/twenty-docker/scripts/install.sh +++ b/packages/twenty-docker/scripts/install.sh @@ -93,9 +93,8 @@ fi echo "# === Randomly generated secret ===" >>.env echo "APP_SECRET=$(openssl rand -base64 32)" >>.env -# Issue with Postgres spilo? -#echo "" >>.env -#echo "PGPASSWORD_SUPERUSER=$(openssl rand -hex 16)" >>.env +echo "" >>.env +echo "PGPASSWORD_SUPERUSER=$(openssl rand -hex 16)" >>.env echo -e "\t• .env configuration completed" From 6578d4eac741248b1c38e3f034f882fe2a07f16c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Malfait?= Date: Wed, 22 Jan 2025 11:04:34 +0100 Subject: [PATCH 4/8] Charles PR comment --- .github/workflows/ci-test-docker-compose.yaml | 2 +- packages/twenty-docker/.env.example | 2 +- packages/twenty-docker/scripts/install.sh | 8 ++++---- .../content/developers/self-hosting/docker-compose.mdx | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci-test-docker-compose.yaml b/.github/workflows/ci-test-docker-compose.yaml index 21a8db3863df..f530cb434a7a 100644 --- a/.github/workflows/ci-test-docker-compose.yaml +++ b/.github/workflows/ci-test-docker-compose.yaml @@ -39,7 +39,7 @@ jobs: echo "Generating secrets..." echo "# === Randomly generated secrets ===" >>.env echo "APP_SECRET=$(openssl rand -base64 32)" >>.env - echo "PGPASSWORD_SUPERUSER=$(openssl rand -base64 32)" >>.env + echo "PGPASSWORD_SUPERUSER=$(openssl rand -hex 16)" >>.env echo "Docker compose up..." docker compose up -d || { diff --git a/packages/twenty-docker/.env.example b/packages/twenty-docker/.env.example index 993e68257ee0..ad2c1586b541 100644 --- a/packages/twenty-docker/.env.example +++ b/packages/twenty-docker/.env.example @@ -1,7 +1,7 @@ TAG=latest #PGUSER_SUPERUSER=postgres -#PGPASSWORD_SUPERUSER=replace_me_with_a_url-safe_strong_password +#PGPASSWORD_SUPERUSER=replace_me_with_a_strong_password_without_special_characters #PG_DATABASE_HOST=db #REDIS_URL=redis://redis:6379 diff --git a/packages/twenty-docker/scripts/install.sh b/packages/twenty-docker/scripts/install.sh index 1fcb65c99b02..41425530f4e2 100755 --- a/packages/twenty-docker/scripts/install.sh +++ b/packages/twenty-docker/scripts/install.sh @@ -90,11 +90,11 @@ else fi # Generate random strings for secrets -echo "# === Randomly generated secret ===" >>.env -echo "APP_SECRET=$(openssl rand -base64 32)" >>.env +echo "# === Randomly generated secret ===" >> .env +echo "APP_SECRET=$(openssl rand -base64 32)" >> .env -echo "" >>.env -echo "PGPASSWORD_SUPERUSER=$(openssl rand -hex 16)" >>.env +echo "" >> .env +echo "PGPASSWORD_SUPERUSER=$(openssl rand -hex 16)" >> .env echo -e "\t• .env configuration completed" diff --git a/packages/twenty-website/src/content/developers/self-hosting/docker-compose.mdx b/packages/twenty-website/src/content/developers/self-hosting/docker-compose.mdx index ed1a0780e657..6191aa8206fa 100644 --- a/packages/twenty-website/src/content/developers/self-hosting/docker-compose.mdx +++ b/packages/twenty-website/src/content/developers/self-hosting/docker-compose.mdx @@ -65,7 +65,7 @@ Follow these steps for a manual setup. 4. **Set the Postgres Password** - Update the `PGPASSWORD_SUPERUSER` value in the .env file with a strong password that is URL-safe. + Update the `PGPASSWORD_SUPERUSER` value in the .env file with a strong password without special characters. ```ini PGPASSWORD_SUPERUSER=my_strong_password From b9c9a643fb31a32ac877ebc9cb9c334c5b38e003 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Malfait?= Date: Wed, 22 Jan 2025 11:11:11 +0100 Subject: [PATCH 5/8] Ultimate fix --- packages/twenty-docker/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/twenty-docker/docker-compose.yml b/packages/twenty-docker/docker-compose.yml index c8978564e31c..c83ed546ce14 100644 --- a/packages/twenty-docker/docker-compose.yml +++ b/packages/twenty-docker/docker-compose.yml @@ -47,7 +47,7 @@ services: image: twentycrm/twenty:${TAG:-latest} command: ["yarn", "worker:prod"] environment: - PG_DATABASE_URL: "postgres://${PGUSER_SUPERUSER:-postgres}:${PGPASSWORD_SUPERUSER:-postgres}@${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} REDIS_URL: ${REDIS_URL:-redis://redis:6379} DISABLE_DB_MIGRATIONS: "true" # it already runs on the server From a3fb85b3486a91568be9825129eccf548ac494cb Mon Sep 17 00:00:00 2001 From: john-s4d Date: Wed, 22 Jan 2025 09:35:58 -0500 Subject: [PATCH 6/8] revert PG_DATABASE_URL interpolation --- packages/twenty-docker/docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/twenty-docker/docker-compose.yml b/packages/twenty-docker/docker-compose.yml index c83ed546ce14..df3293cbfc40 100644 --- a/packages/twenty-docker/docker-compose.yml +++ b/packages/twenty-docker/docker-compose.yml @@ -21,7 +21,7 @@ services: - "3000:3000" environment: PORT: 3000 - PG_DATABASE_URL: "postgres://${PGUSER_SUPERUSER:-postgres}:${PGPASSWORD_SUPERUSER:-postgres}@${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} REDIS_URL: ${REDIS_URL:-redis://redis:6379} @@ -47,7 +47,7 @@ services: image: twentycrm/twenty:${TAG:-latest} command: ["yarn", "worker:prod"] environment: - PG_DATABASE_URL: "postgres://${PGUSER_SUPERUSER:-postgres}:${PGPASSWORD_SUPERUSER:-postgres}@${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} REDIS_URL: ${REDIS_URL:-redis://redis:6379} DISABLE_DB_MIGRATIONS: "true" # it already runs on the server From 9ee000e940954589f3f117036811747cdbbca615 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Malfait?= Date: Fri, 24 Jan 2025 11:33:15 +0100 Subject: [PATCH 7/8] Introduce database port --- packages/twenty-docker/.env.example | 5 +++-- packages/twenty-docker/docker-compose.yml | 10 +++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/twenty-docker/.env.example b/packages/twenty-docker/.env.example index ad2c1586b541..344c20c32b3f 100644 --- a/packages/twenty-docker/.env.example +++ b/packages/twenty-docker/.env.example @@ -1,8 +1,9 @@ TAG=latest -#PGUSER_SUPERUSER=postgres -#PGPASSWORD_SUPERUSER=replace_me_with_a_strong_password_without_special_characters +#PG_DATABASE_USER=postgres +#PG_DATABASE_PASSWORD=replace_me_with_a_strong_password_without_special_characters #PG_DATABASE_HOST=db +#PG_DATABASE_PORT=5432 #REDIS_URL=redis://redis:6379 SERVER_URL=http://localhost:3000 diff --git a/packages/twenty-docker/docker-compose.yml b/packages/twenty-docker/docker-compose.yml index df3293cbfc40..8222f9b0339c 100644 --- a/packages/twenty-docker/docker-compose.yml +++ b/packages/twenty-docker/docker-compose.yml @@ -21,7 +21,7 @@ services: - "3000:3000" environment: PORT: 3000 - PG_DATABASE_URL: postgres://${PGUSER_SUPERUSER:-postgres}:${PGPASSWORD_SUPERUSER:-postgres}@${PG_DATABASE_HOST:-db:5432}/default + PG_DATABASE_URL: postgres://${PG_DATABASE_USER:-postgres}:${PG_DATABASE_PASSWORD:-postgres}@${PG_DATABASE_HOST:-db}:${PG_DATABASE_PORT:-5432}/default SERVER_URL: ${SERVER_URL} REDIS_URL: ${REDIS_URL:-redis://redis:6379} @@ -47,7 +47,7 @@ services: image: twentycrm/twenty:${TAG:-latest} command: ["yarn", "worker:prod"] environment: - PG_DATABASE_URL: postgres://${PGUSER_SUPERUSER:-postgres}:${PGPASSWORD_SUPERUSER:-postgres}@${PG_DATABASE_HOST:-db:5432}/default + PG_DATABASE_URL: postgres://${PG_DATABASE_USER:-postgres}:${PG_DATABASE_PASSWORD:-postgres}@${PG_DATABASE_HOST:-db}:${PG_DATABASE_PORT:-5432}/default SERVER_URL: ${SERVER_URL} REDIS_URL: ${REDIS_URL:-redis://redis:6379} DISABLE_DB_MIGRATIONS: "true" # it already runs on the server @@ -70,12 +70,12 @@ services: volumes: - db-data:/home/postgres/pgdata environment: - PGUSER_SUPERUSER: ${PGUSER_SUPERUSER:-postgres} - PGPASSWORD_SUPERUSER: ${PGPASSWORD_SUPERUSER:-postgres} + PGUSER_SUPERUSER: ${PG_DATABASE_USER:-postgres} + PGPASSWORD_SUPERUSER: ${PG_DATABASE_PASSWORD:-postgres} ALLOW_NOSSL: "true" SPILO_PROVIDER: "local" healthcheck: - test: pg_isready -U ${PGUSER_SUPERUSER:-postgres} -h localhost -d postgres + test: pg_isready -U ${PG_DATABASE_USER:-postgres} -h localhost -d postgres interval: 5s timeout: 5s retries: 10 From f09debcb2154c2e6f6311f9b6211174c070abc81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Malfait?= Date: Fri, 24 Jan 2025 11:34:45 +0100 Subject: [PATCH 8/8] Install script --- packages/twenty-docker/scripts/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/twenty-docker/scripts/install.sh b/packages/twenty-docker/scripts/install.sh index 41425530f4e2..320696d13914 100755 --- a/packages/twenty-docker/scripts/install.sh +++ b/packages/twenty-docker/scripts/install.sh @@ -94,7 +94,7 @@ echo "# === Randomly generated secret ===" >> .env echo "APP_SECRET=$(openssl rand -base64 32)" >> .env echo "" >> .env -echo "PGPASSWORD_SUPERUSER=$(openssl rand -hex 16)" >> .env +echo "PG_DATABASE_PASSWORD=$(openssl rand -hex 16)" >> .env echo -e "\t• .env configuration completed"