meltedchoco commited on
Commit
9b29b82
Β·
verified Β·
1 Parent(s): 0bc275b

Update entrypoint.sh

Browse files
Files changed (1) hide show
  1. entrypoint.sh +6 -5
entrypoint.sh CHANGED
@@ -1,14 +1,15 @@
1
  #!/usr/bin/env bash
2
  set -euo pipefail
3
 
4
- PGDATA="/tmp/postgres"
5
- PGHOST="/tmp"
6
- PG_PORT=5432
 
7
  SEKAI_DB_URL="postgresql://sekai:sekai@/sekai?host=${PGHOST}&port=${PG_PORT}"
8
 
9
  # ── Initialize Postgres if needed ────────────────────────────────────
10
  if [ ! -f "${PGDATA}/PG_VERSION" ]; then
11
- echo "Initializing PostgreSQL database..."
12
  mkdir -p "${PGDATA}"
13
  chmod 700 "${PGDATA}" # ← postgres requires exactly 0700
14
  initdb --auth=trust --no-locale --encoding=UTF8 "${PGDATA}"
@@ -39,4 +40,4 @@ export SEKAI_DATABASE_URL="${SEKAI_DB_URL}"
39
  echo "PostgreSQL ready at ${PGHOST}:${PG_PORT}"
40
 
41
  # ── Start the app ────────────────────────────────────────────────────
42
- exec uv run python main.py
 
1
  #!/usr/bin/env bash
2
  set -euo pipefail
3
 
4
+ # Use environment variables if they exist, otherwise fallback to /tmp
5
+ PGDATA="${PGDATA:-/data/postgres}"
6
+ PGHOST="${PGHOST:-/tmp}"
7
+ PG_PORT="${PG_PORT:-5432}"
8
  SEKAI_DB_URL="postgresql://sekai:sekai@/sekai?host=${PGHOST}&port=${PG_PORT}"
9
 
10
  # ── Initialize Postgres if needed ────────────────────────────────────
11
  if [ ! -f "${PGDATA}/PG_VERSION" ]; then
12
+ echo "Initializing PostgreSQL database in ${PGDATA}..."
13
  mkdir -p "${PGDATA}"
14
  chmod 700 "${PGDATA}" # ← postgres requires exactly 0700
15
  initdb --auth=trust --no-locale --encoding=UTF8 "${PGDATA}"
 
40
  echo "PostgreSQL ready at ${PGHOST}:${PG_PORT}"
41
 
42
  # ── Start the app ────────────────────────────────────────────────────
43
+ exec uv run python main.py