diff --git a/deploy/docker/fs/opt/appsmith/entrypoint.sh b/deploy/docker/fs/opt/appsmith/entrypoint.sh index 0587dec423..0c83f22fd6 100644 --- a/deploy/docker/fs/opt/appsmith/entrypoint.sh +++ b/deploy/docker/fs/opt/appsmith/entrypoint.sh @@ -390,9 +390,13 @@ init_postgres() { echo "Checking initialized local postgres" POSTGRES_DB_PATH="$stacks_path/data/postgres/main" - if [ -e "$POSTGRES_DB_PATH/PG_VERSION" ]; then - echo "Found existing Postgres, Skipping initialization" - chown -R postgres:postgres "$POSTGRES_DB_PATH" + mkdir -p "$POSTGRES_DB_PATH" "$TMP/pg-runtime" + + # Postgres does not allow it's server to be run with super user access, we use user postgres and the file system owner also needs to be the same user postgres + chown -R postgres:postgres "$POSTGRES_DB_PATH" "$TMP/pg-runtime" + + if [[ -e "$POSTGRES_DB_PATH/PG_VERSION" ]]; then + echo "Found existing Postgres, Skipping initialization" else echo "Initializing local postgresql database" mkdir -p "$POSTGRES_DB_PATH" @@ -402,6 +406,7 @@ init_postgres() { # Initialize the postgres db file system su postgres -c "/usr/lib/postgresql/13/bin/initdb -D $POSTGRES_DB_PATH" + sed -Ei "s,^#(unix_socket_directories =).*,\\1 '$TMP/pg-runtime'," "$POSTGRES_DB_PATH/postgresql.conf" # Start the postgres server in daemon mode su postgres -c "/usr/lib/postgresql/13/bin/pg_ctl -D $POSTGRES_DB_PATH start"