From 47494ea928ed28f3ddcd2f85eb638af11d295437 Mon Sep 17 00:00:00 2001 From: Adish M Date: Mon, 28 Apr 2025 18:39:06 +0530 Subject: [PATCH 1/8] Fix: Render postgresql connection pool issue --- docker/ce-entrypoint.sh | 2 ++ docker/ce-preview.Dockerfile | 33 +++++++++++++++++++++++++++------ 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/docker/ce-entrypoint.sh b/docker/ce-entrypoint.sh index 4b63af2e45..7c1ae7a518 100755 --- a/docker/ce-entrypoint.sh +++ b/docker/ce-entrypoint.sh @@ -1,6 +1,8 @@ #!/bin/bash set -e +service postgresql start + if [ -d "./server/dist" ]; then SETUP_CMD='npm run db:setup:prod' else diff --git a/docker/ce-preview.Dockerfile b/docker/ce-preview.Dockerfile index 4e9f8dd796..b0bf238fa8 100644 --- a/docker/ce-preview.Dockerfile +++ b/docker/ce-preview.Dockerfile @@ -79,16 +79,37 @@ COPY ./docker/ce-entrypoint.sh ./app/server/entrypoint.sh WORKDIR /app +USER postgres +RUN service postgresql start && \ + psql -c "create role tooljet with login superuser password 'postgres';" +USER root + # ENV defaults -ENV TOOLJET_HOST=http://localhost:80 \ - PGRST_HOST=http://localhost:3000 \ - PGRST_JWT_SECRET=r9iMKoe5CRMgvJBBtp4HrqN7QiPpUToj \ - TOOLJET_DB=tooljet_db \ - ENABLE_TOOLJET_DB=true \ +ENV TOOLJET_HOST=http://localhost \ PORT=80 \ + NODE_ENV=production \ LOCKBOX_MASTER_KEY=replace_with_lockbox_master_key \ SECRET_KEY_BASE=replace_with_secret_key_base \ - ORM_LOGGING=all \ + PG_DB=tooljet_production \ + PG_USER=tooljet \ + PG_PASS=postgres \ + PG_HOST=localhost \ + ENABLE_TOOLJET_DB=true \ + TOOLJET_DB_HOST=localhost \ + TOOLJET_DB_USER=tooljet \ + 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 \ + PGRST_DB_PRE_CONFIG=postgrest.pre_config \ + ORM_LOGGING=true \ + DEPLOYMENT_PLATFORM=docker:local \ + HOME=/home/appuser \ + REDIS_HOST=localhost \ + REDIS_PORT=6379 \ + REDIS_USER=default \ + REDIS_PASS= \ TERM=xterm CMD ["/usr/bin/supervisord"] From b5991a7a126a0072e08992887f7a3d8b5c2a230f Mon Sep 17 00:00:00 2001 From: Adish M Date: Mon, 28 Apr 2025 19:00:00 +0530 Subject: [PATCH 2/8] correction to pick up the password from the env and not hardcode it --- .github/workflows/render-preview-deploy.yml | 22 +++++---------------- docker/ce-entrypoint.sh | 11 +++++++++++ docker/ce-preview.Dockerfile | 6 +++--- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/.github/workflows/render-preview-deploy.yml b/.github/workflows/render-preview-deploy.yml index 203ee88150..8ca5ef23f0 100644 --- a/.github/workflows/render-preview-deploy.yml +++ b/.github/workflows/render-preview-deploy.yml @@ -72,7 +72,7 @@ jobs: "envVars": [ { "key": "PG_HOST", - "value": "${{ secrets.RENDER_PG_HOST }}" + "value": "localhost" }, { "key": "PG_PORT", @@ -80,7 +80,7 @@ jobs: }, { "key": "PG_USER", - "value": "${{ secrets.RENDER_PG_USER }}" + "value": "tooljet" }, { "key": "PG_PASS", @@ -96,11 +96,11 @@ jobs: }, { "key": "TOOLJET_DB_HOST", - "value": "${{ secrets.RENDER_PG_HOST }}" + "value": "localhost" }, { "key": "TOOLJET_DB_USER", - "value": "${{ secrets.RENDER_PG_USER }}" + "value": "tooljet" }, { "key": "TOOLJET_DB_PASS", @@ -116,7 +116,7 @@ jobs: }, { "key": "PGRST_DB_URI", - "value": "postgres://${{ secrets.RENDER_PG_USER }}:${{ secrets.RENDER_PG_PASS }}@${{ secrets.RENDER_PG_HOST }}/${{ env.PR_NUMBER }}-ce-tjdb" + "value": "postgres://tooljet:${{ secrets.RENDER_PG_PASS }}@localhost/${{ env.PR_NUMBER }}-ce-tjdb" }, { "key": "PGRST_HOST", @@ -162,18 +162,6 @@ jobs: "key": "SMTP_PASSWORD", "value": "${{ secrets.RENDER_SMTP_PASSWORD }}" }, - { - "key": "TEMPORAL_SERVER_ADDRESS", - "value": "https://auto-setup-1-25-1.onrender.com" - }, - { - "key": "TEMPORAL_TASK_QUEUE_NAME_FOR_WORKFLOWS", - "value": "tooljet-ce-pr-${{ env.PR_NUMBER }}" - }, - { - "key": "TOOLJET_WORKFLOWS_TEMPORAL_NAMESPACE", - "value": "default" - }, { "key": "TOOLJET_MARKETPLACE_URL", "value": "${{ secrets.MARKETPLACE_BUCKET }}" diff --git a/docker/ce-entrypoint.sh b/docker/ce-entrypoint.sh index 7c1ae7a518..738028a436 100755 --- a/docker/ce-entrypoint.sh +++ b/docker/ce-entrypoint.sh @@ -1,8 +1,19 @@ #!/bin/bash set -e +if [ -f "./.env" ]; then + export $(grep -v '^#' ./.env | xargs -d '\n') || true +fi + +# Start Postgres service postgresql start +# Create role if it doesn't exist +if ! PGPASSWORD="$PG_PASS" psql -U postgres -tAc "SELECT 1 FROM pg_roles WHERE rolname='${PG_USER}'" | grep -q 1; then + echo "Creating role ${PG_USER} with password from PG_PASS env variable..." + PGPASSWORD="$PG_PASS" psql -U postgres -c "CREATE ROLE ${PG_USER} WITH LOGIN SUPERUSER PASSWORD '${PG_PASS}';" +fi + if [ -d "./server/dist" ]; then SETUP_CMD='npm run db:setup:prod' else diff --git a/docker/ce-preview.Dockerfile b/docker/ce-preview.Dockerfile index b0bf238fa8..e0e3cf0312 100644 --- a/docker/ce-preview.Dockerfile +++ b/docker/ce-preview.Dockerfile @@ -79,10 +79,10 @@ COPY ./docker/ce-entrypoint.sh ./app/server/entrypoint.sh WORKDIR /app -USER postgres -RUN service postgresql start && \ - psql -c "create role tooljet with login superuser password 'postgres';" USER root +RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - +RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ bullseye-pgdg main" | tee /etc/apt/sources.list.d/pgdg.list +RUN apt update && apt -y install postgresql-13 postgresql-client-13 supervisor # ENV defaults ENV TOOLJET_HOST=http://localhost \ From 73e5fbf89999cd7dbb20302e20cf178a0c54f1aa Mon Sep 17 00:00:00 2001 From: Adish M Date: Tue, 29 Apr 2025 07:54:35 +0530 Subject: [PATCH 3/8] correction render yaml --- .github/workflows/render-preview-deploy.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/render-preview-deploy.yml b/.github/workflows/render-preview-deploy.yml index 8ca5ef23f0..1deb3f7f0a 100644 --- a/.github/workflows/render-preview-deploy.yml +++ b/.github/workflows/render-preview-deploy.yml @@ -12,7 +12,7 @@ permissions: jobs: -# Community Edition +# Community Edition CE create-ce-review-app: if: ${{ github.event.action == 'labeled' && (github.event.label.name == 'create-ce-review-app' || github.event.label.name == 'review-app') }} runs-on: ubuntu-latest @@ -84,7 +84,7 @@ jobs: }, { "key": "PG_PASS", - "value": "${{ secrets.RENDER_PG_PASS }}" + "value": "postgres" }, { "key": "PG_DB", @@ -104,7 +104,7 @@ jobs: }, { "key": "TOOLJET_DB_PASS", - "value": "${{ secrets.RENDER_PG_PASS }}" + "value": "postgres" }, { "key": "TOOLJET_DB_PORT", @@ -116,7 +116,7 @@ jobs: }, { "key": "PGRST_DB_URI", - "value": "postgres://tooljet:${{ secrets.RENDER_PG_PASS }}@localhost/${{ env.PR_NUMBER }}-ce-tjdb" + "value": "postgres://tooljet:postgres@localhost/${{ env.PR_NUMBER }}-ce-tjdb" }, { "key": "PGRST_HOST", @@ -1112,4 +1112,3 @@ jobs: # } catch (e) { # console.log(e) # } - From c60e75a067d58bc1bd88f3cd854676228faafc4e Mon Sep 17 00:00:00 2001 From: Adish M Date: Tue, 29 Apr 2025 07:57:51 +0530 Subject: [PATCH 4/8] adding dockerfile and boot.sh file change for postgresql --- docker/ce-preview.Dockerfile | 8 ++++--- docker/ee/ee-preview.Dockerfile | 38 +++++++++++++++++++++++++-------- server/scripts/boot.sh | 4 ++++ 3 files changed, 38 insertions(+), 12 deletions(-) diff --git a/docker/ce-preview.Dockerfile b/docker/ce-preview.Dockerfile index e0e3cf0312..d1f4145812 100644 --- a/docker/ce-preview.Dockerfile +++ b/docker/ce-preview.Dockerfile @@ -75,18 +75,20 @@ COPY --from=builder /app/server/templates ./app/server/templates COPY --from=builder /app/server/scripts ./app/server/scripts COPY --from=builder /app/server/dist ./app/server/dist -COPY ./docker/ce-entrypoint.sh ./app/server/entrypoint.sh - WORKDIR /app USER root RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ bullseye-pgdg main" | tee /etc/apt/sources.list.d/pgdg.list +RUN echo "deb http://deb.debian.org/debian" RUN apt update && apt -y install postgresql-13 postgresql-client-13 supervisor +USER postgres +RUN service postgresql start && \ + psql -c "create role tooljet with login superuser password 'postgres';" +USER root # ENV defaults ENV TOOLJET_HOST=http://localhost \ - PORT=80 \ NODE_ENV=production \ LOCKBOX_MASTER_KEY=replace_with_lockbox_master_key \ SECRET_KEY_BASE=replace_with_secret_key_base \ diff --git a/docker/ee/ee-preview.Dockerfile b/docker/ee/ee-preview.Dockerfile index d88efbfecf..91e0864bd0 100644 --- a/docker/ee/ee-preview.Dockerfile +++ b/docker/ee/ee-preview.Dockerfile @@ -104,20 +104,40 @@ COPY --from=builder /app/server/templates ./app/server/templates COPY --from=builder /app/server/scripts ./app/server/scripts COPY --from=builder /app/server/dist ./app/server/dist -COPY ./docker/ee/ee-entrypoint.sh ./app/server/ee-entrypoint.sh - WORKDIR /app # ENV defaults -ENV TOOLJET_HOST=http://localhost:80 \ - PGRST_HOST=http://localhost:3000 \ - PGRST_JWT_SECRET=r9iMKoe5CRMgvJBBtp4HrqN7QiPpUToj \ - TOOLJET_DB=tooljet_db \ - ENABLE_TOOLJET_DB=true \ - PORT=80 \ +USER root +RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - +RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ bullseye-pgdg main" | tee /etc/apt/sources.list.d/pgdg.list +RUN echo "deb http://deb.debian.org/debian" +RUN apt update && apt -y install postgresql-13 postgresql-client-13 supervisor +USER postgres +RUN service postgresql start && \ + psql -c "create role tooljet with login superuser password 'postgres';" +USER root + +# ENV defaults +ENV TOOLJET_HOST=http://localhost \ + NODE_ENV=production \ LOCKBOX_MASTER_KEY=replace_with_lockbox_master_key \ SECRET_KEY_BASE=replace_with_secret_key_base \ - ORM_LOGGING=all \ + PG_DB=tooljet_production \ + PG_USER=tooljet \ + PG_PASS=postgres \ + PG_HOST=localhost \ + ENABLE_TOOLJET_DB=true \ + TOOLJET_DB_HOST=localhost \ + TOOLJET_DB_USER=tooljet \ + 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 \ + PGRST_DB_PRE_CONFIG=postgrest.pre_config \ + ORM_LOGGING=true \ + DEPLOYMENT_PLATFORM=docker:local \ + REDIS_PASS= \ TERM=xterm CMD ["/usr/bin/supervisord"] diff --git a/server/scripts/boot.sh b/server/scripts/boot.sh index e12aa43a25..42d0aba1d3 100755 --- a/server/scripts/boot.sh +++ b/server/scripts/boot.sh @@ -1,6 +1,10 @@ #!/bin/bash set -e +service postgresql start + +redis-server /etc/redis/redis.conf & + echo " _____ _ ___ _ |_ _| | | |_ | | | From ff9567a87604d285ce01cf8ce250a95a39a1e001 Mon Sep 17 00:00:00 2001 From: Adish M Date: Tue, 29 Apr 2025 08:35:15 +0530 Subject: [PATCH 5/8] remove redis boot.sh file --- server/scripts/boot.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/server/scripts/boot.sh b/server/scripts/boot.sh index 42d0aba1d3..3c2bbad93e 100755 --- a/server/scripts/boot.sh +++ b/server/scripts/boot.sh @@ -3,8 +3,6 @@ set -e service postgresql start -redis-server /etc/redis/redis.conf & - echo " _____ _ ___ _ |_ _| | | |_ | | | From c4523cc4cd3e1ebc7bfc38fecafd0adece7bbd9b Mon Sep 17 00:00:00 2001 From: Adish M Date: Tue, 29 Apr 2025 08:53:02 +0530 Subject: [PATCH 6/8] added change in EE edition PR app --- .github/workflows/render-preview-deploy.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/render-preview-deploy.yml b/.github/workflows/render-preview-deploy.yml index 1deb3f7f0a..d1ca481d02 100644 --- a/.github/workflows/render-preview-deploy.yml +++ b/.github/workflows/render-preview-deploy.yml @@ -412,7 +412,7 @@ jobs: "envVars": [ { "key": "PG_HOST", - "value": "${{ secrets.RENDER_PG_HOST }}" + "value": "localhost" }, { "key": "PG_PORT", @@ -420,11 +420,11 @@ jobs: }, { "key": "PG_USER", - "value": "${{ secrets.RENDER_PG_USER }}" + "value": "tooljet" }, { "key": "PG_PASS", - "value": "${{ secrets.RENDER_PG_PASS }}" + "value": "postgres" }, { "key": "PG_DB", @@ -436,15 +436,15 @@ jobs: }, { "key": "TOOLJET_DB_HOST", - "value": "${{ secrets.RENDER_PG_HOST }}" + "value": "localhost" }, { "key": "TOOLJET_DB_USER", - "value": "${{ secrets.RENDER_PG_USER }}" + "value": "tooljet" }, { "key": "TOOLJET_DB_PASS", - "value": "${{ secrets.RENDER_PG_PASS }}" + "value": "postgres" }, { "key": "TOOLJET_DB_PORT", @@ -456,7 +456,7 @@ jobs: }, { "key": "PGRST_DB_URI", - "value": "postgres://${{ secrets.RENDER_PG_USER }}:${{ secrets.RENDER_PG_PASS }}@${{ secrets.RENDER_PG_HOST }}/${{ env.PR_NUMBER }}-ee-tjdb" + "value": "postgres://tooljet:postgres@localhost/${{ env.PR_NUMBER }}-ee-tjdb" }, { "key": "PGRST_HOST", From f696d15355bab041420c3bf0e19c015de99b1729 Mon Sep 17 00:00:00 2001 From: Adish M Date: Tue, 29 Apr 2025 09:45:00 +0530 Subject: [PATCH 7/8] remove redis ce-preview dockerfile --- docker/ce-preview.Dockerfile | 4 ---- 1 file changed, 4 deletions(-) diff --git a/docker/ce-preview.Dockerfile b/docker/ce-preview.Dockerfile index d1f4145812..d71e6c1dbc 100644 --- a/docker/ce-preview.Dockerfile +++ b/docker/ce-preview.Dockerfile @@ -108,10 +108,6 @@ ENV TOOLJET_HOST=http://localhost \ ORM_LOGGING=true \ DEPLOYMENT_PLATFORM=docker:local \ HOME=/home/appuser \ - REDIS_HOST=localhost \ - REDIS_PORT=6379 \ - REDIS_USER=default \ - REDIS_PASS= \ TERM=xterm CMD ["/usr/bin/supervisord"] From c16c6dc84e926c76925d338153d29c5eaea0bf2a Mon Sep 17 00:00:00 2001 From: Adish M Date: Tue, 29 Apr 2025 09:47:06 +0530 Subject: [PATCH 8/8] clean up entrypoint.sh --- docker/ce-entrypoint.sh | 9 --------- 1 file changed, 9 deletions(-) diff --git a/docker/ce-entrypoint.sh b/docker/ce-entrypoint.sh index 738028a436..b18ab59ffd 100755 --- a/docker/ce-entrypoint.sh +++ b/docker/ce-entrypoint.sh @@ -5,15 +5,6 @@ if [ -f "./.env" ]; then export $(grep -v '^#' ./.env | xargs -d '\n') || true fi -# Start Postgres -service postgresql start - -# Create role if it doesn't exist -if ! PGPASSWORD="$PG_PASS" psql -U postgres -tAc "SELECT 1 FROM pg_roles WHERE rolname='${PG_USER}'" | grep -q 1; then - echo "Creating role ${PG_USER} with password from PG_PASS env variable..." - PGPASSWORD="$PG_PASS" psql -U postgres -c "CREATE ROLE ${PG_USER} WITH LOGIN SUPERUSER PASSWORD '${PG_PASS}';" -fi - if [ -d "./server/dist" ]; then SETUP_CMD='npm run db:setup:prod' else