| set -e | |
| # Persistent storage at /data (HuggingFace Spaces mounts this) | |
| mkdir -p /data/postgres /data/redis /data/storage /var/run/postgresql | |
| # Initialize PostgreSQL if first run | |
| if [ ! -f /data/postgres/PG_VERSION ]; then | |
| chown -R postgres:postgres /data/postgres | |
| su postgres -c "/usr/lib/postgresql/15/bin/initdb -D /data/postgres" | |
| cat > /data/postgres/pg_hba.conf <<EOF | |
| local all all trust | |
| host all all 127.0.0.1/32 trust | |
| EOF | |
| cat >> /data/postgres/postgresql.conf <<EOF | |
| listen_addresses = 'localhost' | |
| port = 5432 | |
| EOF | |
| fi | |
| chown -R postgres:postgres /data/postgres | |
| # Start supervisord (manages all services) | |
| exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf | |