#!/bin/sh # Create necessary directories in the persistent /data volume echo "Creating necessary directories in the persistent /data volume..." mkdir -p /data/postgresql/data /data/postgresql/run chmod 0700 /data/postgresql/data chmod 0755 /data/postgresql/run # Initialize PostgreSQL if not already initialized echo "Initializing PostgreSQL if not already initialized..." if [ ! -f "/data/postgresql/data/PG_VERSION" ]; then # Initialize database initdb -D /data/postgresql/data # Modify pg_hba.conf to allow local connections echo "local all all trust" > /data/postgresql/data/pg_hba.conf echo "host all all 127.0.0.1/32 trust" >> /data/postgresql/data/pg_hba.conf fi # Start PostgreSQL with the persistent directories echo "Starting PostgreSQL..." pg_ctl -D /data/postgresql/data -o "-c listen_addresses='*' -c unix_socket_directories='/data/postgresql/run'" start # Create database and roles echo "Creating database and roles..." createuser -s postgres || true createuser -s node || true createdb postgres || true # Wait for PostgreSQL to be ready echo "Waiting for PostgreSQL to be ready..." until pg_isready -h /data/postgresql/run; do echo "Waiting for PostgreSQL to be ready..." sleep 1 done # Update DATABASE_URL to use the correct socket directory export DATABASE_URL="postgresql://postgres:postgres@%2Fdata%2Fpostgresql%2Frun:5432/postgres" # Run the original entrypoint script ./web/entrypoint.sh node ./web/server.js --keepAliveTimeout 110000