Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Create appsmith postgres DB to be used by internal processes #36670

Merged
merged 4 commits into from
Oct 8, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions deploy/docker/fs/opt/appsmith/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ tlog "Running as: $(id)"

stacks_path=/appsmith-stacks

export APPSMITH_PG_DATABASE="appsmith"
export SUPERVISORD_CONF_TARGET="$TMP/supervisor-conf.d/" # export for use in supervisord.conf
export MONGODB_TMP_KEY_PATH="$TMP/mongodb-key" # export for use in supervisor process mongodb.conf

Expand Down Expand Up @@ -432,6 +433,7 @@ init_postgres() {
tlog "Initializing local Postgres data folder"
su postgres -c "env PATH='$PATH' initdb -D $POSTGRES_DB_PATH"
fi
create_appsmith_pg_db "$POSTGRES_DB_PATH"
else
runEmbeddedPostgres=0
fi
Expand All @@ -453,6 +455,26 @@ safe_init_postgres() {
fi
}

create_appsmith_pg_db() {
POSTGRES_DB_PATH=$1
# Start the postgres , wait for it to be ready and create a appsmith db
su postgres -c "env PATH='$PATH' pg_ctl -D $POSTGRES_DB_PATH -l $POSTGRES_DB_PATH/logfile start"
echo "Waiting for Postgres to start"
until su postgres -c "env PATH='$PATH' pg_isready -d postgres"; do
tlog "Waiting for Postgres to be ready..."
sleep 1
done
# Check if the appsmith DB is present
DB_EXISTS=$(su postgres -c "env PATH='$PATH' psql -tAc \"SELECT 1 FROM pg_database WHERE datname='${APPSMITH_PG_DATABASE}'\"")

if [[ "$DB_EXISTS" != "1" ]]; then
su postgres -c "env PATH='$PATH' psql -c 'CREATE DATABASE ${APPSMITH_PG_DATABASE}'"
abhvsn marked this conversation as resolved.
Show resolved Hide resolved
else
echo "Database ${APPSMITH_PG_DATABASE} already exists."
fi
su postgres -c "env PATH='$PATH' pg_ctl -D $POSTGRES_DB_PATH stop"
}
abhvsn marked this conversation as resolved.
Show resolved Hide resolved

setup_caddy() {
if [[ "$APPSMITH_RATE_LIMIT" == "disabled" ]]; then
export _APPSMITH_CADDY="/opt/caddy/caddy_vanilla"
Expand Down
Loading