From 51c91f8a679e378f54b0a25fbd80477ae1455b24 Mon Sep 17 00:00:00 2001 From: Shrikant Sharat Kandula Date: Tue, 23 Jan 2024 10:42:18 +0530 Subject: [PATCH] chore: Changes to Postgres to support readonly root FS (#30517) --- deploy/docker/fs/opt/appsmith/entrypoint.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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"