Skip to content

Commit 681e80a

Browse files
committed
Add Docker Compose and environment configuration for built-in and external PostgreSQL setups
1 parent aa84035 commit 681e80a

9 files changed

Lines changed: 61 additions & 39 deletions

File tree

deploy/docker/.env.internal.example renamed to deploy/docker/docker-compose-with-built-in-postgresql/.env.internal.example

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ TOOLJET_DB_HOST=postgresql
2222
TOOLJET_DB_PASS=
2323

2424
PGRST_DB_URI= # postgres://<postgres_username>:<postgres_password><@postgres_hostname>/<database_name>
25-
PGRST_HOST=postgrest
25+
PGRST_HOST=localhost:3001
2626
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.
27+
PGRST_SERVER_PORT=3001
28+
PGRST_DB_PRE_CONFIG=postgrest.pre_config
2729

2830
# Checks every 24 hours to see if a new version of ToolJet is available
2931
# (Enabled by default. Set false to disable)

deploy/docker/docker-compose-db.yaml renamed to deploy/docker/docker-compose-with-built-in-postgresql/docker-compose.yaml

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ services:
55
tty: true
66
stdin_open: true
77
container_name: Tooljet-app
8-
image: tooljet/tooljet-ce:latest
8+
image: tooljet/tooljet-ce:ce-lts-latest
99
restart: always
1010
env_file: .env
1111
ports:
@@ -28,17 +28,6 @@ services:
2828
- POSTGRES_USER=${PG_USER}
2929
- POSTGRES_PASSWORD=${PG_PASS}
3030

31-
postgrest:
32-
container_name: postgrest
33-
image: postgrest/postgrest:v12.0.2
34-
restart: always
35-
depends_on:
36-
- postgres
37-
env_file: .env
38-
environment:
39-
- PGRST_SERVER_PORT=80
40-
- PGRST_DB_PRE_CONFIG=postgrest.pre_config
41-
4231
volumes:
4332
postgres:
4433
driver: local

deploy/docker/internal.sh renamed to deploy/docker/docker-compose-with-built-in-postgresql/internal.sh

File renamed without changes.

deploy/docker/.env.external.example renamed to deploy/docker/docker-compose-with-external-postgresql/.env.external.example

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ TOOLJET_DB_USER= # Postgres database username
2222
TOOLJET_DB_HOST= # Postgres database host
2323
TOOLJET_DB_PASS= # Postgres database password
2424

25-
PGRST_HOST=postgrest
25+
PGRST_HOST=localhost:3001
2626
PGRST_DB_URI=
2727
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.
28-
28+
PGRST_SERVER_PORT=3001
29+
PGRST_DB_PRE_CONFIG=postgrest.pre_config
2930

3031
# Checks every 24 hours to see if a new version of ToolJet is available
3132
# (Enabled by default. Set false to disable)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
version: "3"
2+
3+
services:
4+
tooljet:
5+
tty: true
6+
stdin_open: true
7+
container_name: Tooljet-app
8+
image: tooljet/tooljet-ce:ce-lts-latest
9+
restart: always
10+
env_file: .env
11+
ports:
12+
- 80:80
13+
environment:
14+
SERVE_CLIENT: "true"
15+
PORT: "80"
16+
command: npm run start:prod

deploy/docker/external.sh renamed to deploy/docker/docker-compose-with-external-postgresql/external.sh

File renamed without changes.

deploy/docker/docker-compose.yaml

Lines changed: 0 additions & 24 deletions
This file was deleted.

docker/ce-entrypoint.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,24 @@ if [ -f "./.env" ]; then
55
export $(grep -v '^#' ./.env | xargs -d '\n') || true
66
fi
77

8+
# Check if PGRST_HOST starts with "localhost"
9+
if [[ "$PGRST_HOST" == localhost:* ]]; then
10+
echo "Starting PostgREST server locally..."
11+
12+
# Generate PostgREST configuration in a writable directory
13+
POSTGREST_CONFIG_PATH="/tmp/postgrest.conf"
14+
15+
echo "db-uri = \"${PGRST_DB_URI}\"" > "$POSTGREST_CONFIG_PATH"
16+
echo "db-pre-config = \"postgrest.pre_config\"" >> "$POSTGREST_CONFIG_PATH"
17+
echo "server-port = \"${PGRST_SERVER_PORT}\"" >> "$POSTGREST_CONFIG_PATH"
18+
19+
# Starting PostgREST
20+
echo "Starting PostgREST..."
21+
postgrest "$POSTGREST_CONFIG_PATH" &
22+
else
23+
echo "Using external PostgREST at $PGRST_HOST."
24+
fi
25+
826
if [ -d "./server/dist" ]; then
927
SETUP_CMD='npm run db:setup:prod'
1028
else

docker/ce-production.Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,19 @@ RUN npm install -g @nestjs/cli
3535
RUN npm install -g copyfiles
3636
RUN npm --prefix server run build
3737

38+
# Install dependencies for PostgREST, curl, tar, etc.
39+
RUN apt-get update && apt-get install -y \
40+
curl ca-certificates tar \
41+
&& rm -rf /var/lib/apt/lists/*
42+
43+
ENV POSTGREST_VERSION=v12.2.0
44+
45+
RUN curl -Lo postgrest.tar.xz https://github.com/PostgREST/postgrest/releases/download/${POSTGREST_VERSION}/postgrest-v12.2.0-linux-static-x64.tar.xz && \
46+
tar -xf postgrest.tar.xz && \
47+
mv postgrest /postgrest && \
48+
rm postgrest.tar.xz && \
49+
chmod +x /postgrest
50+
3851
FROM debian:12
3952

4053
RUN apt-get update -yq \
@@ -103,6 +116,13 @@ RUN useradd --create-home --home-dir /home/appuser appuser \
103116
&& chmod u+x /app \
104117
&& chmod -R g=u /app
105118

119+
# Use the PostgREST binary from the builder stage
120+
COPY --from=builder --chown=appuser:0 /postgrest /usr/local/bin/postgrest
121+
122+
RUN mv /usr/local/bin/postgrest /usr/local/bin/postgrest-original && \
123+
echo '#!/bin/bash\nexec /usr/local/bin/postgrest-original "$@" 2>&1 | sed "s/^/[PostgREST] /"' > /usr/local/bin/postgrest && \
124+
chmod +x /usr/local/bin/postgrest
125+
106126
# Set npm cache directory
107127
ENV npm_config_cache /home/appuser/.npm
108128

0 commit comments

Comments
 (0)