From 40f1254d7134ab19cfaa7a8cfddaa2ecaa5c1362 Mon Sep 17 00:00:00 2001 From: Souvik Date: Mon, 16 Feb 2026 19:56:11 +0530 Subject: [PATCH] Fix customer deployment issue - Docker (Contributors) --- docker-compose.yaml | 17 ++++++ docker/.env.internal.example | 82 +++++++++++++++++++++++++++ docker/client.Dockerfile.dev | 4 +- docker/internal.sh | 101 ++++++++++++++++++++++++++++++++++ docker/plugins.Dockerfile.dev | 4 +- docker/server.Dockerfile.dev | 4 +- 6 files changed, 206 insertions(+), 6 deletions(-) create mode 100644 docker/.env.internal.example create mode 100755 docker/internal.sh diff --git a/docker-compose.yaml b/docker-compose.yaml index fd70edd199..4904a887af 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -78,5 +78,22 @@ services: - POSTGRES_USER=${PG_USER} - POSTGRES_PASSWORD=${PG_PASS} + redis: + container_name: redis + image: redis:6.2 + restart: always + deploy: + resources: + limits: + cpus: '0.5' + memory: 1G + env_file: + - .env + environment: + - MASTER=redis + - REDIS_USER=${REDIS_USER} + - REDIS_PASSWORD=${REDIS_PASSWORD} + volumes: postgres: + redis: diff --git a/docker/.env.internal.example b/docker/.env.internal.example new file mode 100644 index 0000000000..54c8fc9c6a --- /dev/null +++ b/docker/.env.internal.example @@ -0,0 +1,82 @@ +# Create .env from this example file and replace values for the environment. +# The application expects a separate .env.test for test environment configuration +# Get detailed information about each variable here: https://docs.tooljet.com/docs/setup/env-vars + +TOOLJET_HOST=http://localhost:8082 +LOCKBOX_MASTER_KEY= # replace_with_lockbox_master_key +SECRET_KEY_BASE= # replace_with_secret_key_base + +# DATABASE CONFIG +ORM_LOGGING=all +PG_DB=tooljet_production +PG_USER=postgres +PG_HOST=postgresql +PG_PASS= # postgres database password + +# The above postgres values is set to its default state. If necessary, kindly modify it according to your personal preference. + +# TOOLJET DATABASE +TOOLJET_DB=tooljet_db +TOOLJET_DB_USER=postgres +TOOLJET_DB_HOST=postgresql +TOOLJET_DB_PASS= + +PGRST_DB_URI= # postgres://:<@postgres_hostname>/ +PGRST_HOST=postgrest:3002 +PGRST_JWT_SECRET= # If you have openssl installed, you can run the following command openssl rand -hex 32 to generate the value for PGRST_JWT_SECRET. +PGRST_SERVER_PORT=3002 +PGRST_DB_PRE_CONFIG=postgrest.pre_config + +# Redis configuration +REDIS_HOST=redis +REDIS_PORT=6379 +REDIS_USER=default +REDIS_PASSWORD= +# Checks every 24 hours to see if a new version of ToolJet is available +# (Enabled by default. Set false to disable) +CHECK_FOR_UPDATES=true + +# Checks every 24 hours to update app telemetry data to ToolJet hub. +# (Telemetry is enabled by default. Set value to true to disable.) +# DISABLE_TOOLJET_TELEMETRY=false + +GOOGLE_CLIENT_ID= +GOOGLE_CLIENT_SECRET= + +# EMAIL CONFIGURATION +DEFAULT_FROM_EMAIL=hello@tooljet.io +SMTP_USERNAME= +SMTP_PASSWORD= +SMTP_DOMAIN= +SMTP_PORT= + +# DISABLE USER SIGNUPS (true or false). only applicable if Multi-Workspace feature is enabled +DISABLE_SIGNUPS= + + +# OBSERVABILITY +APM_VENDOR= +SENTRY_DNS= +SENTRY_DEBUG= + +# FEATURE TOGGLE +COMMENT_FEATURE_ENABLE= +ENABLE_MULTIPLAYER_EDITING=true + + +# SSO (Applicable only for Multi-Workspace) +SSO_GOOGLE_OAUTH2_CLIENT_ID= +SSO_GIT_OAUTH2_CLIENT_ID= +SSO_GIT_OAUTH2_CLIENT_SECRET= +SSO_GIT_OAUTH2_HOST= +SSO_ACCEPTED_DOMAINS= +SSO_DISABLE_SIGNUPS= + +#ONBOARDING +ENABLE_ONBOARDING_QUESTIONS_FOR_ALL_SIGN_UPS= + +#session expiry in minutes +USER_SESSION_EXPIRY=2880 + +#TELEMETRY +DEPLOYMENT_PLATFORM=docker diff --git a/docker/client.Dockerfile.dev b/docker/client.Dockerfile.dev index bc10ed730f..53de89c1be 100644 --- a/docker/client.Dockerfile.dev +++ b/docker/client.Dockerfile.dev @@ -1,9 +1,9 @@ # pull official base image -FROM node:18.18.2-bullseye +FROM node:22.15.1-bullseye ENV NODE_ENV=development -RUN npm i -g npm@9.8.1 +RUN npm i -g npm@10.9.2 # set working directory WORKDIR /app diff --git a/docker/internal.sh b/docker/internal.sh new file mode 100755 index 0000000000..17f0b52e2b --- /dev/null +++ b/docker/internal.sh @@ -0,0 +1,101 @@ +#!/bin/bash + +# Load the .env file +source .env + +# Check if LOCKBOX_MASTER_KEY is present or empty +if [[ -z "$LOCKBOX_MASTER_KEY" ]]; then + # Generate LOCKBOX_MASTER_KEY + LOCKBOX_MASTER_KEY=$(openssl rand -hex 32) + + # Update .env file + awk -v key="$LOCKBOX_MASTER_KEY" ' + BEGIN { FS=OFS="=" } + /^LOCKBOX_MASTER_KEY=/ { $2=key; found=1 } + 1 + END { if (!found) print "LOCKBOX_MASTER_KEY="key } + ' .env > temp.env && mv temp.env .env + + echo "Generated a secure master key for the lockbox" +else + echo "The lockbox master key already exists." +fi + +# Check if SECRET_KEY_BASE is present or empty +if [[ -z "$SECRET_KEY_BASE" ]]; then + # Generate SECRET_KEY_BASE + SECRET_KEY_BASE=$(openssl rand -hex 64) + + # Update .env file + awk -v key="$SECRET_KEY_BASE" ' + BEGIN { FS=OFS="=" } + /^SECRET_KEY_BASE=/ { $2=key; found=1 } + 1 + END { if (!found) print "SECRET_KEY_BASE="key } + ' .env > temp.env && mv temp.env .env + + echo "Created a secret key for secure operations." +else + echo "The secret key base is already in place." +fi + +# Check if PGRST_JWT_SECRET is present or empty +if [[ -z "$PGRST_JWT_SECRET" ]]; then + # Generate PGRST_JWT_SECRET + PGRST_JWT_SECRET=$(openssl rand -hex 32) + + # Update .env file + awk -v key="$PGRST_JWT_SECRET" ' + BEGIN { FS=OFS="=" } + /^PGRST_JWT_SECRET=/ { $2=key; found=1 } + 1 + END { if (!found) print "PGRST_JWT_SECRET="key } + ' .env > temp.env && mv temp.env .env + + echo "Generated a unique secret for PGRST authentication." +else + echo "The PGRST JWT secret is already generated and in place." +fi + +# Function to generate a random password +generate_password() { + openssl rand -base64 12 | tr -d '/+' | cut -c1-16 +} + +# Check if PG_PASS and TOOLJET_DB_PASS are present or empty +if [[ -z "$PG_PASS" ]] && [[ -z "$TOOLJET_DB_PASS" ]]; then + # Generate random passwords + PASSWORD=$(generate_password) + + # Update .env file + awk -v pass="$PASSWORD" ' + BEGIN { FS=OFS="=" } + /^(PG_PASS|TOOLJET_DB_PASS)=/ { $2=pass; found=1 } + 1 + END { if (!found) print "PG_PASS="pass ORS "TOOLJET_DB_PASS="pass } + ' .env > temp.env && mv temp.env .env + + echo "Successfully generated a secure password for the PostgreSQL database." +else + echo "Postgres password already exist" +fi + +# Check if PGRST_DB_URI is present or empty +if [[ -z "$PGRST_DB_URI" ]]; then + # Construct PGRST_DB_URI with PG_PASS + PGRST_DB_URI="postgres://postgres:$PASSWORD@postgresql/tooljet_db" + + # Update .env file for PGRST_DB_URI + awk -v uri="$PGRST_DB_URI" ' + BEGIN { FS=OFS="=" } + /^PGRST_DB_URI=/ { $2=uri; found=1 } + 1 + END { if (!found) print "PGRST_DB_URI="uri } + ' .env > temp.env && mv temp.env .env + + echo "Successfully updated PGRST database URI" +else + echo "The PGRST DB URI is already configured and in use." +fi + +exec "$@" \ No newline at end of file diff --git a/docker/plugins.Dockerfile.dev b/docker/plugins.Dockerfile.dev index fbb30410d4..42a0043588 100644 --- a/docker/plugins.Dockerfile.dev +++ b/docker/plugins.Dockerfile.dev @@ -1,7 +1,7 @@ # pull official base image -FROM node:18.18.2-bullseye +FROM node:22.15.1-bullseye -RUN npm i -g npm@9.8.1 +RUN npm i -g npm@10.9.2 # set working directory WORKDIR /app diff --git a/docker/server.Dockerfile.dev b/docker/server.Dockerfile.dev index c47b5a4d1e..d23344e192 100644 --- a/docker/server.Dockerfile.dev +++ b/docker/server.Dockerfile.dev @@ -1,5 +1,5 @@ # pull official base image -FROM node:18.18.2-bullseye +FROM node:22.15.1-bullseye RUN apt-get update && apt-get install -y postgresql-client freetds-dev libaio1 wget # Install Instantclient Basic Light Oracle and Dependencies @@ -19,7 +19,7 @@ WORKDIR / ENV NODE_ENV=development ENV NODE_OPTIONS="--max-old-space-size=4096" -RUN npm i -g npm@9.8.1 +RUN npm i -g npm@10.9.2 RUN mkdir -p /app WORKDIR /app