Seth McKnight commited on
Commit
ffd8fdb
·
2 Parent(s): fa40b0e d3fd68c

Merge branch 'main' into postgres-vector-migration

Browse files
Files changed (2) hide show
  1. Dockerfile +5 -1
  2. run.sh +14 -2
Dockerfile CHANGED
@@ -17,10 +17,14 @@ COPY static /app/static
17
  COPY src /app/src
18
  # Copy persisted data (e.g., chroma DB) so the container can access it if present
19
  COPY data /app/data
 
 
 
20
  COPY run.sh /app/run.sh
21
 
22
- # Make run.sh executable
23
  RUN chmod +x /app/run.sh
 
24
 
25
  # Expose port 10000
26
  EXPOSE 10000
 
17
  COPY src /app/src
18
  # Copy persisted data (e.g., chroma DB) so the container can access it if present
19
  COPY data /app/data
20
+ # COPY the scripts directory so runtime init scripts (e.g. init_pgvector.py) exist
21
+ COPY scripts /app/scripts
22
+
23
  COPY run.sh /app/run.sh
24
 
25
+ # Make run.sh (and optionally the init script) executable
26
  RUN chmod +x /app/run.sh
27
+ RUN chmod +x /app/scripts/init_pgvector.py || true
28
 
29
  # Expose port 10000
30
  EXPOSE 10000
run.sh CHANGED
@@ -6,9 +6,21 @@ WORKERS_VALUE="${WORKERS:-1}"
6
  TIMEOUT_VALUE="${TIMEOUT:-120}"
7
  PORT_VALUE="${PORT:-10000}"
8
 
9
- # Initialize the database
10
  echo "Initializing database..."
11
- python scripts/init_pgvector.py
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
  echo "Starting gunicorn on port ${PORT_VALUE} with ${WORKERS_VALUE} workers and timeout ${TIMEOUT_VALUE}s"
14
  export PYTHONPATH="/app${PYTHONPATH:+:$PYTHONPATH}"
 
6
  TIMEOUT_VALUE="${TIMEOUT:-120}"
7
  PORT_VALUE="${PORT:-10000}"
8
 
9
+ # Initialize the database with retries (handle DB cold start)
10
  echo "Initializing database..."
11
+ MAX_RETRIES="${DB_INIT_RETRIES:-10}"
12
+ SLEEP_BASE="${DB_INIT_SLEEP_BASE:-5}"
13
+
14
+ i=1
15
+ until python scripts/init_pgvector.py; do
16
+ if [ "$i" -ge "$MAX_RETRIES" ]; then
17
+ echo "Database initialization failed after $i attempts; exiting."
18
+ exit 1
19
+ fi
20
+ echo "init_pgvector.py failed (attempt $i/$MAX_RETRIES). Sleeping $((SLEEP_BASE * i))s before retry..."
21
+ sleep $((SLEEP_BASE * i))
22
+ i=$((i + 1))
23
+ done
24
 
25
  echo "Starting gunicorn on port ${PORT_VALUE} with ${WORKERS_VALUE} workers and timeout ${TIMEOUT_VALUE}s"
26
  export PYTHONPATH="/app${PYTHONPATH:+:$PYTHONPATH}"