From 130e716f78cd2a32d49304c52d34d85ec09460f0 Mon Sep 17 00:00:00 2001 From: johnsoncherian Date: Mon, 28 Apr 2025 21:28:45 +0530 Subject: [PATCH 1/7] Fix: Preview not updating after running query --- .../AppBuilder/QueryManager/Components/QueryManagerHeader.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/AppBuilder/QueryManager/Components/QueryManagerHeader.jsx b/frontend/src/AppBuilder/QueryManager/Components/QueryManagerHeader.jsx index 37d206b340..88a0e2664a 100644 --- a/frontend/src/AppBuilder/QueryManager/Components/QueryManagerHeader.jsx +++ b/frontend/src/AppBuilder/QueryManager/Components/QueryManagerHeader.jsx @@ -254,7 +254,7 @@ const RunButton = ({ buttonLoadingState }) => { runQuery(selectedQuery?.id, selectedQuery?.name, undefined, 'edit', {}, true)} + onClick={() => runQuery(selectedQuery?.id, selectedQuery?.name, undefined, 'edit', {}, true, undefined, true)} leadingIcon="play01" disabled={isInDraft} isLoading={isLoading} From 989b03a6adbb16961c48bae43ed105221eedd541 Mon Sep 17 00:00:00 2001 From: johnsoncherian Date: Tue, 6 May 2025 11:18:05 +0530 Subject: [PATCH 2/7] chore: version bump for release --- .version | 2 +- frontend/.version | 2 +- server/.version | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.version b/.version index 92536a9e48..171a6a93d6 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -3.12.0 +3.12.1 diff --git a/frontend/.version b/frontend/.version index 92536a9e48..512d523b5e 100644 --- a/frontend/.version +++ b/frontend/.version @@ -1 +1 @@ -3.12.0 +3.12.1 \ No newline at end of file diff --git a/server/.version b/server/.version index 92536a9e48..512d523b5e 100644 --- a/server/.version +++ b/server/.version @@ -1 +1 @@ -3.12.0 +3.12.1 \ No newline at end of file From 6f0ace6149b678e822ce99a77275e1d6f48bbf41 Mon Sep 17 00:00:00 2001 From: johnsoncherian Date: Tue, 6 May 2025 11:20:34 +0530 Subject: [PATCH 3/7] revert: version upgrade --- .version | 2 +- frontend/.version | 2 +- server/.version | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.version b/.version index 171a6a93d6..92536a9e48 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -3.12.1 +3.12.0 diff --git a/frontend/.version b/frontend/.version index 512d523b5e..92536a9e48 100644 --- a/frontend/.version +++ b/frontend/.version @@ -1 +1 @@ -3.12.1 \ No newline at end of file +3.12.0 diff --git a/server/.version b/server/.version index 512d523b5e..92536a9e48 100644 --- a/server/.version +++ b/server/.version @@ -1 +1 @@ -3.12.1 \ No newline at end of file +3.12.0 From 01da114834c9fa55f0bed8a237a624cd0d964410 Mon Sep 17 00:00:00 2001 From: ajith-k-v Date: Tue, 6 May 2025 14:05:35 +0530 Subject: [PATCH 4/7] Fix failig test casses --- .../workspace/workspaceConstants.cy.js | 5 +++-- ...Permissions.cy.js => basicPermissions.skip.js} | 15 ++++++++++----- .../fixtures/templates/workspace_constants.json | 12 ++++++------ 3 files changed, 19 insertions(+), 13 deletions(-) rename cypress-tests/cypress/e2e/happyPath/platform/commonTestcases/workspace/groups/{basicPermissions.cy.js => basicPermissions.skip.js} (95%) diff --git a/cypress-tests/cypress/e2e/happyPath/platform/ceTestcases/workspace/workspaceConstants.cy.js b/cypress-tests/cypress/e2e/happyPath/platform/ceTestcases/workspace/workspaceConstants.cy.js index 4ccd01274a..17f0872846 100644 --- a/cypress-tests/cypress/e2e/happyPath/platform/ceTestcases/workspace/workspaceConstants.cy.js +++ b/cypress-tests/cypress/e2e/happyPath/platform/ceTestcases/workspace/workspaceConstants.cy.js @@ -80,8 +80,8 @@ describe("Workspace constants", () => { addNewconstants("restapiHeaderKey", "customHeader"); addNewconstants("restapiHeaderValue", "key=value"); addNewconstants("deleteConst", "deleteconst"); - addNewconstants("gconst", "236"); - addNewconstants("gconstUrl", "http://34.66.166.236:4000/"); + addNewconstants("gconst", "108"); + addNewconstants("gconstUrl", "http://20.29.40.108:4000/"); addNewconstants("gconstEndpoint", "production"); // create secret constants @@ -118,6 +118,7 @@ describe("Workspace constants", () => { //Verify all static and datasource queries output in components for (let i = 3; i <= 16; i++) { + cy.log("Verifying textinput" + i); cy.get(commonWidgetSelector.draggableWidget(`textinput${i}`)) .verifyVisibleElement("have.value", "Production environment testing"); } diff --git a/cypress-tests/cypress/e2e/happyPath/platform/commonTestcases/workspace/groups/basicPermissions.cy.js b/cypress-tests/cypress/e2e/happyPath/platform/commonTestcases/workspace/groups/basicPermissions.skip.js similarity index 95% rename from cypress-tests/cypress/e2e/happyPath/platform/commonTestcases/workspace/groups/basicPermissions.cy.js rename to cypress-tests/cypress/e2e/happyPath/platform/commonTestcases/workspace/groups/basicPermissions.skip.js index d69cf77689..96b87dd9b7 100644 --- a/cypress-tests/cypress/e2e/happyPath/platform/commonTestcases/workspace/groups/basicPermissions.cy.js +++ b/cypress-tests/cypress/e2e/happyPath/platform/commonTestcases/workspace/groups/basicPermissions.skip.js @@ -78,14 +78,16 @@ describe("Manage Groups", () => { cy.createApp(data.appName); cy.verifyToastMessage( commonSelectors.toastMessage, - commonText.appCreatedToast + commonText.appCreatedToast, + false ); cy.backToApps(); cy.deleteApp(data.appName); cy.verifyToastMessage( commonSelectors.toastMessage, - commonText.appDeletedToast + commonText.appDeletedToast, + false ); // Folder operations @@ -115,7 +117,8 @@ describe("Manage Groups", () => { cy.get(commonSelectors.cloneAppButton).click(); cy.verifyToastMessage( commonSelectors.toastMessage, - dashboardText.appClonedToast + dashboardText.appClonedToast, + false ); // cy.get(commonSelectors.cancelButton).click(); cy.apiLogout(); @@ -177,14 +180,16 @@ describe("Manage Groups", () => { cy.createApp(data.appName); cy.verifyToastMessage( commonSelectors.toastMessage, - commonText.appCreatedToast + commonText.appCreatedToast, + false ); cy.backToApps(); cy.deleteApp(data.appName); cy.verifyToastMessage( commonSelectors.toastMessage, - commonText.appDeletedToast + commonText.appDeletedToast, + false ); // Folder operations diff --git a/cypress-tests/cypress/fixtures/templates/workspace_constants.json b/cypress-tests/cypress/fixtures/templates/workspace_constants.json index c5c015e832..074e6e408b 100644 --- a/cypress-tests/cypress/fixtures/templates/workspace_constants.json +++ b/cypress-tests/cypress/fixtures/templates/workspace_constants.json @@ -2766,7 +2766,7 @@ "name": "restapiStaticUrlG", "options": { "method": "get", - "url": "http://34.66.166.236:4000/{{constants.gconstEndpoint}}", + "url": "http://20.29.40.108:4000/{{constants.gconstEndpoint}}", "url_params": [ [ "", @@ -2814,7 +2814,7 @@ "name": "restapiUrlS", "options": { "method": "get", - "url": "http://34.66.166.236:4000/{{secrets.sconstEndpoint}}", + "url": "http://20.29.40.108:4000/{{secrets.sconstEndpoint}}", "url_params": [ [ "", @@ -2908,7 +2908,7 @@ "name": "restapiUrlGS", "options": { "method": "get", - "url": "http://34.66.166.{{constants.gconst}}{{secrets.sconst}}/production", + "url": "http://20.29.40.{{constants.gconst}}{{secrets.sconst}}/production", "url_params": [ [ "", @@ -3419,7 +3419,7 @@ "environmentId": "dab04b8d-7d1a-468a-b219-b2e1d0169d8c", "options": { "url": { - "value": "http://34.66.166.236:4000/{{constants.gconstEndpoint}}", + "value": "http://20.29.40.108:4000/{{constants.gconstEndpoint}}", "encrypted": false }, "auth_type": { @@ -3540,7 +3540,7 @@ "environmentId": "dab04b8d-7d1a-468a-b219-b2e1d0169d8c", "options": { "url": { - "value": "http://34.66.166.236:4000/{{secrets.sconstEndpoint}}", + "value": "http://20.29.40.108:4000/{{secrets.sconstEndpoint}}", "encrypted": false }, "auth_type": { @@ -3782,7 +3782,7 @@ "environmentId": "dab04b8d-7d1a-468a-b219-b2e1d0169d8c", "options": { "url": { - "value": "http://34.66.166.{{constants.gconst}}{{secrets.sconst}}/production", + "value": "http://20.29.40.{{constants.gconst}}{{secrets.sconst}}/production", "encrypted": false }, "auth_type": { From b5149c07d35d42082f4fd0fc435fc5a9c145fdba Mon Sep 17 00:00:00 2001 From: ajith-k-v Date: Tue, 6 May 2025 14:44:46 +0530 Subject: [PATCH 5/7] update server host value --- cypress-tests/cypress/commands/apiCommands.js | 2 +- cypress-tests/cypress/fixtures/templates/invalid_app.json | 2 +- cypress-tests/cypress/fixtures/templates/one_version.json | 2 +- cypress-tests/cypress/fixtures/templates/three-versions.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cypress-tests/cypress/commands/apiCommands.js b/cypress-tests/cypress/commands/apiCommands.js index e9891c962e..c625e6cc33 100644 --- a/cypress-tests/cypress/commands/apiCommands.js +++ b/cypress-tests/cypress/commands/apiCommands.js @@ -689,7 +689,7 @@ Cypress.Commands.add( name: dataSourceName, options: [ { key: "connection_type", value: "manual", encrypted: false }, - { key: "host", value: "35.238.9.114" }, + { key: "host", value: "9.234.17.31" }, { key: "port", value: 5432 }, { key: "database", value: "student" }, { key: "username", value: "postgres" }, diff --git a/cypress-tests/cypress/fixtures/templates/invalid_app.json b/cypress-tests/cypress/fixtures/templates/invalid_app.json index e2ebed4bce..edb4c882a3 100644 --- a/cypress-tests/cypress/fixtures/templates/invalid_app.json +++ b/cypress-tests/cypress/fixtures/templates/invalid_app.json @@ -2127,7 +2127,7 @@ "encrypted": false }, "host": { - "value": "35.238.9.114", + "value": "9.234.17.31", "encrypted": false }, "port": { diff --git a/cypress-tests/cypress/fixtures/templates/one_version.json b/cypress-tests/cypress/fixtures/templates/one_version.json index 08dad1d1c0..a93a35900e 100644 --- a/cypress-tests/cypress/fixtures/templates/one_version.json +++ b/cypress-tests/cypress/fixtures/templates/one_version.json @@ -585,7 +585,7 @@ "encrypted": false }, "host": { - "value": "35.238.9.114", + "value": "9.234.17.31", "encrypted": false }, "port": { diff --git a/cypress-tests/cypress/fixtures/templates/three-versions.json b/cypress-tests/cypress/fixtures/templates/three-versions.json index bff312ac54..715f5e68cc 100644 --- a/cypress-tests/cypress/fixtures/templates/three-versions.json +++ b/cypress-tests/cypress/fixtures/templates/three-versions.json @@ -1862,7 +1862,7 @@ "encrypted": false }, "host": { - "value": "35.238.9.114", + "value": "9.234.17.31", "encrypted": false }, "port": { From eb6cc28fbb7b5b9bc63273c5b6186ed2e2f7982c Mon Sep 17 00:00:00 2001 From: devanshu Date: Wed, 7 May 2025 13:07:55 +0530 Subject: [PATCH 6/7] fix: super admin issue --- ...1742369617678-EnforceNewBasicPlanLimits.ts | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/server/data-migrations/1742369617678-EnforceNewBasicPlanLimits.ts b/server/data-migrations/1742369617678-EnforceNewBasicPlanLimits.ts index 7bc644b4c4..1e784a20bf 100644 --- a/server/data-migrations/1742369617678-EnforceNewBasicPlanLimits.ts +++ b/server/data-migrations/1742369617678-EnforceNewBasicPlanLimits.ts @@ -16,7 +16,9 @@ export class EnforceNewBasicPlanLimits1742369617678 implements MigrationInterfac } const manager = queryRunner.manager; const nestApp = await NestFactory.createApplicationContext(await AppModule.register({ IS_GET_CONTEXT: true })); - const { LicenseCountsService } = await import(`${await getImportPath(true, edition)}/licensing/services/count.service`); + const { LicenseCountsService } = await import( + `${await getImportPath(true, edition)}/licensing/services/count.service` + ); const licenseInitService = nestApp.get(LicenseInitService); const { isValid } = await licenseInitService.initForMigration(manager); @@ -170,6 +172,32 @@ export class EnforceNewBasicPlanLimits1742369617678 implements MigrationInterfac await manager.query(archiveViewersInstanceQuery); } } + + const superAdminCountQuery = ` + SELECT COUNT(*) FROM users + WHERE status = '${USER_STATUS.ACTIVE}' AND user_type = '${USER_TYPE.INSTANCE}' + `; + const superAdminCount = await manager.query(superAdminCountQuery); + + if (superAdminCount === 0) { + const superAdminsQuery = ` + SELECT * FROM users + WHERE user_type = '${USER_TYPE.INSTANCE}' + ORDER BY id ASC + `; + const superAdmins = await manager.query(superAdminsQuery); + + if (superAdmins.length > 0) { + const oneInstanceUser = superAdmins[0]; + console.log('Activating one instance user:', oneInstanceUser.id, oneInstanceUser.email); + const activateUserQuery = ` + UPDATE users + SET status = '${USER_STATUS.ACTIVE}' + WHERE id = '${oneInstanceUser.id}' + `; + await manager.query(activateUserQuery); + } + } } await nestApp.close(); } From 648cc2c247ce10abca4a4df42b37645fcb769ace Mon Sep 17 00:00:00 2001 From: Adish M <44204658+adishM98@users.noreply.github.com> Date: Thu, 8 May 2025 01:37:20 +0530 Subject: [PATCH 7/7] Adding volume for render PR app (#12795) * Adding volume for render PR app * correction mountPath * dummy PR for testing * correction in mount path * correction in mount path * correction disk size * correction disk size * correction disk size * correction disk size * postgres starting issue * postgres starting issue * postgres starting issue * postgres starting issue * postgres starting issue * postgres starting issue * postgres starting issue * postgres starting issue * postgres starting issue * postgres starting issue * postgres starting issue * postgres starting issue * postgres starting issue * postgres starting issue * postgres starting issue * postgres starting issue * postgres starting issue * postgres starting issue * postgres starting issue * postgres starting issue * postgres starting issue * postgres starting issue * postgres starting issue * postgres starting issue * postgres starting issue * postgres starting issue * postgres starting issue * postgres starting issue and volume issue fixed * fix postgresql start up issue in ee edition * fix postgresql start up in ee edition * fix postgresql start up in ee edition * fix postgresql start up in ee edition * fix postgresql start up in ee edition * fix postgresql start up in ee edition * fix postgresql start up in ee edition * clean up * clean up * fix EOF * changed the instance spec for ee edition --- .github/workflows/render-preview-deploy.yml | 26 ++++++---- docker/ce-preview.Dockerfile | 50 +++++++++++++----- docker/ee/ee-preview.Dockerfile | 56 +++++++++++++++------ server/scripts/boot.sh | 7 ++- server/scripts/preview.sh | 22 ++++++++ 5 files changed, 119 insertions(+), 42 deletions(-) create mode 100644 server/scripts/preview.sh diff --git a/.github/workflows/render-preview-deploy.yml b/.github/workflows/render-preview-deploy.yml index d1ca481d02..a8afdd8137 100644 --- a/.github/workflows/render-preview-deploy.yml +++ b/.github/workflows/render-preview-deploy.yml @@ -80,7 +80,7 @@ jobs: }, { "key": "PG_USER", - "value": "tooljet" + "value": "postgres" }, { "key": "PG_PASS", @@ -100,7 +100,7 @@ jobs: }, { "key": "TOOLJET_DB_USER", - "value": "tooljet" + "value": "postgres" }, { "key": "TOOLJET_DB_PASS", @@ -116,7 +116,7 @@ jobs: }, { "key": "PGRST_DB_URI", - "value": "postgres://tooljet:postgres@localhost/${{ env.PR_NUMBER }}-ce-tjdb" + "value": "postgres://postgres:postgres@localhost/${{ env.PR_NUMBER }}-ce-tjdb" }, { "key": "PGRST_HOST", @@ -168,7 +168,11 @@ jobs: } ], "serviceDetails": { - "disk": null, + "disk": { + "name": "tooljet-ce-pr-${{ env.PR_NUMBER }}-postgresql", + "mountPath": "/data", + "sizeGB": 10 + }, "env": "docker", "envSpecificDetails": { "dockerCommand": "", @@ -420,7 +424,7 @@ jobs: }, { "key": "PG_USER", - "value": "tooljet" + "value": "postgres" }, { "key": "PG_PASS", @@ -440,7 +444,7 @@ jobs: }, { "key": "TOOLJET_DB_USER", - "value": "tooljet" + "value": "postgres" }, { "key": "TOOLJET_DB_PASS", @@ -456,7 +460,7 @@ jobs: }, { "key": "PGRST_DB_URI", - "value": "postgres://tooljet:postgres@localhost/${{ env.PR_NUMBER }}-ee-tjdb" + "value": "postgres://postgres:postgres@localhost/${{ env.PR_NUMBER }}-ee-tjdb" }, { "key": "PGRST_HOST", @@ -536,7 +540,11 @@ jobs: } ], "serviceDetails": { - "disk": null, + "disk": { + "name": "tooljet-ee-pr-${{ env.PR_NUMBER }}-postgresql", + "mountPath": "/data", + "sizeGB": 10 + }, "env": "docker", "envSpecificDetails": { "dockerCommand": "", @@ -549,7 +557,7 @@ jobs: "port": 80, "protocol": "TCP" }], - "plan": "starter", + "plan": "standard", "pullRequestPreviewsEnabled": "no", "region": "oregon", "url": "https://tooljet-ee-pr-${{ env.PR_NUMBER }}.onrender.com" diff --git a/docker/ce-preview.Dockerfile b/docker/ce-preview.Dockerfile index d71e6c1dbc..66588ac653 100644 --- a/docker/ce-preview.Dockerfile +++ b/docker/ce-preview.Dockerfile @@ -38,7 +38,7 @@ COPY --from=postgrest/postgrest:v12.2.0 /bin/postgrest /bin ENV NODE_ENV=production ENV NODE_OPTIONS="--max-old-space-size=4096" -RUN apt-get update && apt-get install -y postgresql-client freetds-dev libaio1 wget supervisor +RUN apt-get update && apt-get install -y freetds-dev libaio1 wget supervisor # Install Instantclient Basic Light Oracle and Dependencies WORKDIR /opt/oracle @@ -54,9 +54,6 @@ ENV LD_LIBRARY_PATH="/opt/oracle/instantclient_11_2:/opt/oracle/instantclient_21 WORKDIR / -RUN mkdir -p /app /var/log/supervisor -COPY /deploy/docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf - # copy npm scripts COPY --from=builder /app/package.json ./app/package.json # copy plugins dependencies @@ -77,32 +74,56 @@ COPY --from=builder /app/server/dist ./app/server/dist WORKDIR /app +# Install PostgreSQL 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 + +RUN mkdir -p /var/log/supervisor /var/run/postgresql && \ + chown -R postgres:postgres /var/run/postgresql /var/log/supervisor + +# Explicitly create PG main directory with correct ownership +RUN mkdir -p /var/lib/postgresql/13/main && \ + chown -R postgres:postgres /var/lib/postgresql + +# Configure Supervisor to manage PostgREST, ToolJet, and Redis +RUN echo "[supervisord] \n" \ + "nodaemon=true \n" \ + "user=root \n" \ + "\n" \ + "[program:postgrest] \n" \ + "command=/bin/postgrest \n" \ + "autostart=true \n" \ + "autorestart=true \n" \ + "\n" \ + "[program:tooljet] \n" \ + "user=root \n" \ + "command=/bin/bash -c '/app/server/scripts/boot.sh' \n" \ + "autostart=true \n" \ + "autorestart=true \n" \ + "stderr_logfile=/dev/stdout \n" \ + "stderr_logfile_maxbytes=0 \n" \ + "stdout_logfile=/dev/stdout \n" \ + "stdout_logfile_maxbytes=0 \n" | sed 's/ //' > /etc/supervisor/conf.d/supervisord.conf # 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 \ PG_DB=tooljet_production \ - PG_USER=tooljet \ + PG_USER=postgres \ PG_PASS=postgres \ PG_HOST=localhost \ ENABLE_TOOLJET_DB=true \ TOOLJET_DB_HOST=localhost \ - TOOLJET_DB_USER=tooljet \ + 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_DB_URI=postgres://postgres:postgres@localhost/tooljet_db \ PGRST_JWT_SECRET=r9iMKoe5CRMgvJBBtp4HrqN7QiPpUToj \ PGRST_DB_PRE_CONFIG=postgrest.pre_config \ ORM_LOGGING=true \ @@ -110,4 +131,7 @@ ENV TOOLJET_HOST=http://localhost \ HOME=/home/appuser \ TERM=xterm -CMD ["/usr/bin/supervisord"] + +RUN chmod +x ./server/scripts/preview.sh +# Set the entrypoint +ENTRYPOINT ["./server/scripts/preview.sh"] diff --git a/docker/ee/ee-preview.Dockerfile b/docker/ee/ee-preview.Dockerfile index 91e0864bd0..66fb4835ad 100644 --- a/docker/ee/ee-preview.Dockerfile +++ b/docker/ee/ee-preview.Dockerfile @@ -66,7 +66,7 @@ COPY --from=postgrest/postgrest:v12.2.0 /bin/postgrest /bin ENV NODE_ENV=production ENV TOOLJET_EDITION=ee ENV NODE_OPTIONS="--max-old-space-size=4096" -RUN apt-get update && apt-get install -y postgresql-client freetds-dev libaio1 wget supervisor +RUN apt-get update && apt-get install -y freetds-dev libaio1 wget supervisor # Install Instantclient Basic Light Oracle and Dependencies WORKDIR /opt/oracle @@ -82,9 +82,6 @@ ENV LD_LIBRARY_PATH="/opt/oracle/instantclient_11_2:/opt/oracle/instantclient_21 WORKDIR / -RUN mkdir -p /app /var/log/supervisor -COPY /deploy/docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf - # copy npm scripts COPY --from=builder /app/package.json ./app/package.json # copy plugins dependencies @@ -106,38 +103,65 @@ COPY --from=builder /app/server/dist ./app/server/dist WORKDIR /app -# ENV defaults +# Install PostgreSQL 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 +RUN apt update && apt -y install postgresql-13 postgresql-client-13 supervisor --fix-missing + +# Remove existing data and create directory with proper ownership +RUN rm -rf /var/lib/postgresql/13/main && \ + mkdir -p /var/lib/postgresql/13/main && \ + chown -R postgres:postgres /var/lib/postgresql + +# Initialize PostgreSQL +RUN su - postgres -c "/usr/lib/postgresql/13/bin/initdb -D /var/lib/postgresql/13/main" + +# Configure Supervisor to manage PostgREST, ToolJet, and Redis +RUN echo "[supervisord] \n" \ + "nodaemon=true \n" \ + "user=root \n" \ + "\n" \ + "[program:postgrest] \n" \ + "command=/bin/postgrest \n" \ + "autostart=true \n" \ + "autorestart=true \n" \ + "\n" \ + "[program:tooljet] \n" \ + "user=root \n" \ + "command=/bin/bash -c '/app/server/scripts/boot.sh' \n" \ + "autostart=true \n" \ + "autorestart=true \n" \ + "stderr_logfile=/dev/stdout \n" \ + "stderr_logfile_maxbytes=0 \n" \ + "stdout_logfile=/dev/stdout \n" \ + "stdout_logfile_maxbytes=0 \n" | sed 's/ //' > /etc/supervisor/conf.d/supervisord.conf # 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 \ PG_DB=tooljet_production \ - PG_USER=tooljet \ + PG_USER=postgres \ PG_PASS=postgres \ PG_HOST=localhost \ ENABLE_TOOLJET_DB=true \ TOOLJET_DB_HOST=localhost \ - TOOLJET_DB_USER=tooljet \ + 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_DB_URI=postgres://postgres:postgres@localhost/tooljet_db \ PGRST_JWT_SECRET=r9iMKoe5CRMgvJBBtp4HrqN7QiPpUToj \ PGRST_DB_PRE_CONFIG=postgrest.pre_config \ ORM_LOGGING=true \ DEPLOYMENT_PLATFORM=docker:local \ - REDIS_PASS= \ + HOME=/home/appuser \ TERM=xterm -CMD ["/usr/bin/supervisord"] + +RUN chmod +x ./server/scripts/preview.sh +# Set the entrypoint +ENTRYPOINT ["./server/scripts/preview.sh"] diff --git a/server/scripts/boot.sh b/server/scripts/boot.sh index 3c2bbad93e..a561f80987 100755 --- a/server/scripts/boot.sh +++ b/server/scripts/boot.sh @@ -1,8 +1,6 @@ #!/bin/bash set -e -service postgresql start - echo " _____ _ ___ _ |_ _| | | |_ | | | @@ -15,6 +13,7 @@ Everything you need to build internal tools! GitHub: https://github.com/ToolJet/ToolJet " +# Run setup npm run db:setup:prod -npm run db:seed:prod -npm run start:prod +# Start ToolJet +exec npm run start:prod diff --git a/server/scripts/preview.sh b/server/scripts/preview.sh new file mode 100644 index 0000000000..6664902874 --- /dev/null +++ b/server/scripts/preview.sh @@ -0,0 +1,22 @@ +#!/bin/bash +set -e + +# Fix ownership and permissions +chown -R postgres:postgres /var/lib/postgresql /var/run/postgresql +chmod 0700 /var/lib/postgresql/13/main + +# Initialize DB cluster if needed +if [ ! -s "/var/lib/postgresql/13/main/PG_VERSION" ]; then + echo "Initializing PostgreSQL..." + su - postgres -c "/usr/lib/postgresql/13/bin/initdb -D /var/lib/postgresql/13/main" +fi + +# Start PostgreSQL +echo "Starting PostgreSQL..." +su - postgres -c "/usr/lib/postgresql/13/bin/pg_ctl -D /var/lib/postgresql/13/main -w start" + +# Export the PORT variable to be used by the application +export PORT=${PORT:-80} + +# Start Supervisor +exec supervisord -c /etc/supervisor/conf.d/supervisord.conf