Skip to content

Commit abae4dc

Browse files
authored
feat: update Dockerfiles and entrypoint for PostgreSQL and Temporal integration (#13144)
* feat: update Dockerfiles and entrypoint for PostgreSQL and Temporal integration * fix: update Docker image tags for ee-latest versioning * fix: remove default Dockerfile path and update tag generation logic * fix: remove unnecessary newline in manual Docker build workflow * fix: remove duplicate TOOLJET_EDITION environment variable declaration * fix: update PostgreSQL source list for compatibility and enhance entrypoint script for improved logging and error handling * update PostgreSQL source list to use bookworm for compatibility
1 parent 329a0ab commit abae4dc

9 files changed

Lines changed: 265 additions & 92 deletions

.github/workflows/docker-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ jobs:
142142
BRANCH_NAME=main
143143
file: docker/ee/ee-production.Dockerfile
144144
push: true
145-
tags: tooljet/tooljet-ee:${{ github.event.release.tag_name }},tooljet/tooljet-ee:ee-lts-latest,tooljet/tooljet:ee-lts-latest,tooljet/tooljet:${{ github.event.release.tag_name }}
145+
tags: tooljet/tooljet-ee:${{ github.event.release.tag_name }},tooljet/tooljet-ee:ee-latest,tooljet/tooljet:ee-latest,tooljet/tooljet:${{ github.event.release.tag_name }}
146146
platforms: linux/amd64
147147
env:
148148
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}

.github/workflows/manual-docker-build.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ on:
1010
dockerfile_path:
1111
description: 'Path to Dockerfile'
1212
required: true
13-
default: './Dockerfile'
1413
docker_tag:
1514
description: 'Docker tag suffix (e.g., pre-release-14)'
1615
required: true
@@ -35,13 +34,24 @@ jobs:
3534
username: ${{ secrets.DOCKER_USERNAME }}
3635
password: ${{ secrets.DOCKER_PASSWORD }}
3736

37+
- name: Generate full Docker tag
38+
id: taggen
39+
run: |
40+
input_tag="${{ github.event.inputs.docker_tag }}"
41+
if [[ "$input_tag" == *"/"* ]]; then
42+
echo "tag=$input_tag" >> $GITHUB_OUTPUT
43+
else
44+
echo "tag=tooljet/tj-osv:$input_tag" >> $GITHUB_OUTPUT
45+
fi
46+
3847
- name: Build and Push Docker image
3948
uses: docker/build-push-action@v4
4049
with:
4150
context: .
4251
file: ${{ github.event.inputs.dockerfile_path }}
4352
push: true
44-
tags: tooljet/tj-osv:${{ github.event.inputs.docker_tag }}
53+
tags: ${{ steps.taggen.outputs.tag }}
4554
platforms: linux/amd64
4655
build-args: |
4756
CUSTOM_GITHUB_TOKEN=${{ secrets.CUSTOM_GITHUB_TOKEN }}
57+
BRANCH_NAME=${{ github.event.inputs.branch_name }}

docker/ee/ee-production.Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,16 @@ COPY ./plugins/ ./plugins/
3737
RUN NODE_ENV=production npm --prefix plugins run build
3838
RUN npm --prefix plugins prune --omit=dev
3939

40+
ENV TOOLJET_EDITION=ee
41+
4042
# Build frontend
4143
COPY ./frontend/package.json ./frontend/package-lock.json ./frontend/
4244
RUN npm --prefix frontend install
4345
COPY ./frontend/ ./frontend/
4446
RUN npm --prefix frontend run build --production && npm --prefix frontend prune --production
4547

4648
ENV NODE_ENV=production
49+
ENV TOOLJET_EDITION=ee
4750

4851
# Build server
4952
COPY ./server/package.json ./server/package-lock.json ./server/

docker/ee/ee-try-entrypoint-lts.sh

Lines changed: 89 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,99 @@
11
#!/bin/bash
22
set -e
33

4-
# Install grpcurl if not already installed
5-
if ! command -v grpcurl &> /dev/null; then
6-
echo "grpcurl not found, installing..."
7-
apt update && apt install -y curl \
8-
&& curl -sSL https://github.com/fullstorydev/grpcurl/releases/download/v1.8.0/grpcurl_1.8.0_linux_x86_64.tar.gz | tar -xzv -C /usr/local/bin grpcurl
9-
fi
4+
echo "🚀 Starting Try ToolJet container initialization..."
105

11-
# Start Redis
12-
service redis-server start
6+
# Configure PostgreSQL authentication
7+
echo "🔧 Configuring PostgreSQL authentication..."
8+
sed -i 's/^local\s\+all\s\+postgres\s\+\(peer\|md5\)/local all postgres trust/' /etc/postgresql/13/main/pg_hba.conf >/dev/null 2>&1
9+
sed -i 's/^local\s\+all\s\+all\s\+\(peer\|md5\)/local all all trust/' /etc/postgresql/13/main/pg_hba.conf >/dev/null 2>&1
1310

14-
# Start Postgres
11+
# Start PostgreSQL
12+
echo "📈 Starting PostgreSQL..."
1513
service postgresql start
1614

17-
# Start Temporal Server (SQLite configuration)
18-
echo "Starting Temporal Server..."
19-
/usr/bin/temporal-server -r / -c /etc/temporal/ -e temporal-server start &
15+
# Wait until PostgreSQL is ready
16+
echo "⏳ Waiting for PostgreSQL..."
17+
until pg_isready -h localhost -p 5432; do
18+
echo "PostgreSQL not ready yet, retrying..."
19+
sleep 2
20+
done
21+
22+
# Create user and databases for Temporal
23+
echo "🔧 Creating Temporal DBs and user if needed..."
24+
psql -U postgres -tc "SELECT 1 FROM pg_roles WHERE rolname='tooljet'" | grep -q 1 || \
25+
psql -U postgres -c "CREATE USER tooljet WITH PASSWORD 'postgres' SUPERUSER;" >/dev/null 2>&1
26+
27+
psql -U postgres -tc "SELECT 1 FROM pg_database WHERE datname = 'temporal'" | grep -q 1 || \
28+
psql -U postgres -c "CREATE DATABASE temporal OWNER tooljet;" >/dev/null 2>&1
29+
30+
psql -U postgres -tc "SELECT 1 FROM pg_database WHERE datname = 'temporal_visibility'" | grep -q 1 || \
31+
psql -U postgres -c "CREATE DATABASE temporal_visibility OWNER tooljet;" >/dev/null 2>&1
32+
33+
# Generate Temporal config
34+
echo "🔧 Generating Temporal config..."
35+
mkdir -p /etc/temporal/config
36+
if [ -f /etc/temporal/temporal-server.template.yaml ]; then
37+
envsubst < /etc/temporal/temporal-server.template.yaml > /etc/temporal/config/temporal-server.yaml >/dev/null 2>&1
38+
else
39+
echo "❌ Missing template: /etc/temporal/temporal-server.template.yaml"
40+
exit 1
41+
fi
42+
43+
# Download schema files if not present
44+
if [ ! -d "/etc/temporal/schema/postgresql" ]; then
45+
echo "📥 Downloading Temporal schema files..."
46+
mkdir -p /etc/temporal/schema
47+
cd /tmp
48+
curl -sOL https://github.com/temporalio/temporal/archive/refs/tags/v1.28.0.tar.gz
49+
tar -xzf v1.28.0.tar.gz
50+
cp -r temporal-1.28.0/schema/postgresql /etc/temporal/schema/
51+
rm -rf temporal-1.28.0 v1.28.0.tar.gz
52+
cd /
53+
fi
54+
55+
rm -f /etc/temporal/temporal-sql-tool.yaml ~/.temporal/config.yaml
56+
mkdir -p /tmp/temporal
57+
58+
# Set up schemas
59+
echo "🔧 Setting up Temporal schemas..."
60+
for db in temporal temporal_visibility; do
61+
PGPASSWORD=postgres /usr/bin/temporal-sql-tool --plugin postgres12 \
62+
--ep "localhost" --port 5432 --user tooljet --password postgres \
63+
--database $db setup-schema -v 0.0 >/dev/null 2>&1
64+
65+
schema_dir="/etc/temporal/schema/postgresql/v12"
66+
schema_type=$([ "$db" = "temporal" ] && echo "temporal" || echo "visibility")
2067

21-
# Export the PORT variable to be used by the application
68+
PGPASSWORD=postgres /usr/bin/temporal-sql-tool --plugin postgres12 \
69+
--ep "localhost" --port 5432 --user tooljet --password postgres \
70+
--database $db update-schema -d "$schema_dir/$schema_type/versioned" >/dev/null 2>&1
71+
done
72+
73+
echo "✅ Schema setup complete"
74+
75+
# Export default port if not set
2276
export PORT=${PORT:-80}
2377

78+
# Start Temporal Server
79+
echo "🚀 Starting Temporal Server..."
80+
/usr/bin/temporal-server start >/dev/null 2>&1 &
81+
TEMPORAL_PID=$!
82+
2483
# Start Supervisor
25-
exec supervisord -c /etc/supervisor/conf.d/supervisord.conf &
84+
echo "🚀 Starting Supervisor..."
85+
supervisord -c /etc/supervisor/conf.d/supervisord.conf &
86+
SUPERVISOR_PID=$!
2687

27-
# Wait for Temporal Server to be ready
28-
echo "Waiting for Temporal Server to be ready..."
29-
sleep 10
88+
# Wait for Temporal to become ready
89+
echo "⏳ Waiting for Temporal..."
90+
for i in {1..30}; do
91+
if grpcurl -plaintext localhost:7233 grpc.health.v1.Health/Check >/dev/null 2>&1; then
92+
echo "✅ Temporal is ready"
93+
break
94+
fi
95+
sleep 2
96+
done
3097

3198
# Check if namespace already exists
3299
echo "Checking if Temporal namespace exists..."
@@ -42,6 +109,9 @@ else
42109
}' localhost:7233 temporal.api.workflowservice.v1.WorkflowService/RegisterNamespace
43110
fi
44111

45-
# Run the worker process (last step)
46-
echo "Starting worker process..."
112+
# Wait on background processes
113+
wait $TEMPORAL_PID $SUPERVISOR_PID
114+
115+
# Start worker (last step)
116+
echo "🚀 Starting ToolJet worker..."
47117
npm run worker:prod

docker/ee/ee-try-entrypoint.sh

Lines changed: 90 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,99 @@
11
#!/bin/bash
22
set -e
33

4-
# Install grpcurl if not already installed
5-
if ! command -v grpcurl &> /dev/null; then
6-
echo "grpcurl not found, installing..."
7-
apt update && apt install -y curl \
8-
&& curl -sSL https://github.com/fullstorydev/grpcurl/releases/download/v1.8.0/grpcurl_1.8.0_linux_x86_64.tar.gz | tar -xzv -C /usr/local/bin grpcurl
9-
fi
4+
echo "🚀 Starting Try ToolJet container initialization..."
105

11-
# Start Redis
12-
service redis-server start
6+
# Configure PostgreSQL authentication
7+
echo "🔧 Configuring PostgreSQL authentication..."
8+
sed -i 's/^local\s\+all\s\+postgres\s\+\(peer\|md5\)/local all postgres trust/' /etc/postgresql/13/main/pg_hba.conf >/dev/null 2>&1
9+
sed -i 's/^local\s\+all\s\+all\s\+\(peer\|md5\)/local all all trust/' /etc/postgresql/13/main/pg_hba.conf >/dev/null 2>&1
1310

14-
# Start Postgres
11+
# Start PostgreSQL
12+
echo "📈 Starting PostgreSQL..."
1513
service postgresql start
1614

17-
# Start Temporal Server (SQLite configuration)
18-
echo "Starting Temporal Server..."
19-
/usr/bin/temporal-server -r / -c /etc/temporal/ -e temporal-server start &
15+
# Wait until PostgreSQL is ready
16+
echo "⏳ Waiting for PostgreSQL..."
17+
until pg_isready -h localhost -p 5432; do
18+
echo "PostgreSQL not ready yet, retrying..."
19+
sleep 2
20+
done
21+
22+
# Create user and databases for Temporal
23+
echo "🔧 Creating Temporal DBs and user if needed..."
24+
psql -U postgres -tc "SELECT 1 FROM pg_roles WHERE rolname='tooljet'" | grep -q 1 || \
25+
psql -U postgres -c "CREATE USER tooljet WITH PASSWORD 'postgres' SUPERUSER;" >/dev/null 2>&1
26+
27+
psql -U postgres -tc "SELECT 1 FROM pg_database WHERE datname = 'temporal'" | grep -q 1 || \
28+
psql -U postgres -c "CREATE DATABASE temporal OWNER tooljet;" >/dev/null 2>&1
29+
30+
psql -U postgres -tc "SELECT 1 FROM pg_database WHERE datname = 'temporal_visibility'" | grep -q 1 || \
31+
psql -U postgres -c "CREATE DATABASE temporal_visibility OWNER tooljet;" >/dev/null 2>&1
32+
33+
# Generate Temporal config
34+
echo "🔧 Generating Temporal config..."
35+
mkdir -p /etc/temporal/config
36+
if [ -f /etc/temporal/temporal-server.template.yaml ]; then
37+
envsubst < /etc/temporal/temporal-server.template.yaml > /etc/temporal/config/temporal-server.yaml >/dev/null 2>&1
38+
else
39+
echo "❌ Missing template: /etc/temporal/temporal-server.template.yaml"
40+
exit 1
41+
fi
42+
43+
# Download schema files if not present
44+
if [ ! -d "/etc/temporal/schema/postgresql" ]; then
45+
echo "📥 Downloading Temporal schema files..."
46+
mkdir -p /etc/temporal/schema
47+
cd /tmp
48+
curl -sOL https://github.com/temporalio/temporal/archive/refs/tags/v1.28.0.tar.gz
49+
tar -xzf v1.28.0.tar.gz
50+
cp -r temporal-1.28.0/schema/postgresql /etc/temporal/schema/
51+
rm -rf temporal-1.28.0 v1.28.0.tar.gz
52+
cd /
53+
fi
54+
55+
rm -f /etc/temporal/temporal-sql-tool.yaml ~/.temporal/config.yaml
56+
mkdir -p /tmp/temporal
57+
58+
# Set up schemas
59+
echo "🔧 Setting up Temporal schemas..."
60+
for db in temporal temporal_visibility; do
61+
PGPASSWORD=postgres /usr/bin/temporal-sql-tool --plugin postgres12 \
62+
--ep "localhost" --port 5432 --user tooljet --password postgres \
63+
--database $db setup-schema -v 0.0 >/dev/null 2>&1
64+
65+
schema_dir="/etc/temporal/schema/postgresql/v12"
66+
schema_type=$([ "$db" = "temporal" ] && echo "temporal" || echo "visibility")
2067

21-
# Export the PORT variable to be used by the application
68+
PGPASSWORD=postgres /usr/bin/temporal-sql-tool --plugin postgres12 \
69+
--ep "localhost" --port 5432 --user tooljet --password postgres \
70+
--database $db update-schema -d "$schema_dir/$schema_type/versioned" >/dev/null 2>&1
71+
done
72+
73+
echo "✅ Schema setup complete"
74+
75+
# Export default port if not set
2276
export PORT=${PORT:-80}
2377

78+
# Start Temporal Server
79+
echo "🚀 Starting Temporal Server..."
80+
/usr/bin/temporal-server start >/dev/null 2>&1 &
81+
TEMPORAL_PID=$!
82+
2483
# Start Supervisor
25-
exec supervisord -c /etc/supervisor/conf.d/supervisord.conf &
84+
echo "🚀 Starting Supervisor..."
85+
supervisord -c /etc/supervisor/conf.d/supervisord.conf &
86+
SUPERVISOR_PID=$!
2687

27-
# Wait for Temporal Server to be ready
28-
echo "Waiting for Temporal Server to be ready..."
29-
sleep 10
88+
# Wait for Temporal to become ready
89+
echo "⏳ Waiting for Temporal..."
90+
for i in {1..30}; do
91+
if grpcurl -plaintext localhost:7233 grpc.health.v1.Health/Check >/dev/null 2>&1; then
92+
echo "✅ Temporal is ready"
93+
break
94+
fi
95+
sleep 2
96+
done
3097

3198
# Check if namespace already exists
3299
echo "Checking if Temporal namespace exists..."
@@ -42,6 +109,9 @@ else
42109
}' localhost:7233 temporal.api.workflowservice.v1.WorkflowService/RegisterNamespace
43110
fi
44111

45-
# Run the worker process (last step)
46-
echo "Starting worker process..."
47-
npm run worker:prod
112+
# Wait on background processes
113+
wait $TEMPORAL_PID $SUPERVISOR_PID
114+
115+
# Start worker (last step)
116+
echo "🚀 Starting ToolJet worker..."
117+
npm --prefix server run worker:prod

0 commit comments

Comments
 (0)