Seth McKnight Copilot commited on
Commit
13846a7
·
1 Parent(s): d14a473

Fix Dockerfile and run.sh for gunicorn workers (#58)

Browse files

* Fix Dockerfile and run.sh to resolve 'No module named src' error in gunicorn workers

- Copy src and data directories into container image
- Set PYTHONPATH=/app in run.sh before launching gunicorn

This ensures absolute imports from src.* work in all environments.

* Update run.sh

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>

Files changed (2) hide show
  1. Dockerfile +4 -0
  2. run.sh +1 -0
Dockerfile CHANGED
@@ -13,6 +13,10 @@ RUN pip install --no-cache-dir -r requirements.txt
13
  COPY app.py /app/app.py
14
  COPY templates /app/templates
15
  COPY static /app/static
 
 
 
 
16
  COPY run.sh /app/run.sh
17
 
18
  # Make run.sh executable
 
13
  COPY app.py /app/app.py
14
  COPY templates /app/templates
15
  COPY static /app/static
16
+ # Copy the application package so `import src` works inside the container
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
run.sh CHANGED
@@ -7,4 +7,5 @@ TIMEOUT_VALUE="${TIMEOUT:-120}"
7
  PORT_VALUE="${PORT:-10000}"
8
 
9
  echo "Starting gunicorn on port ${PORT_VALUE} with ${WORKERS_VALUE} workers and timeout ${TIMEOUT_VALUE}s"
 
10
  exec gunicorn --bind 0.0.0.0:${PORT_VALUE} --workers "${WORKERS_VALUE}" --timeout "${TIMEOUT_VALUE}" app:app
 
7
  PORT_VALUE="${PORT:-10000}"
8
 
9
  echo "Starting gunicorn on port ${PORT_VALUE} with ${WORKERS_VALUE} workers and timeout ${TIMEOUT_VALUE}s"
10
+ export PYTHONPATH="/app${PYTHONPATH:+:$PYTHONPATH}"
11
  exec gunicorn --bind 0.0.0.0:${PORT_VALUE} --workers "${WORKERS_VALUE}" --timeout "${TIMEOUT_VALUE}" app:app