Enhance sys.path modification to prevent duplicate entries for current directory
Browse files- Dockerfile +2 -1
- app.py +4 -1
Dockerfile
CHANGED
|
@@ -28,7 +28,7 @@ RUN set -x && \
|
|
| 28 |
# Copy application files
|
| 29 |
COPY app.py .
|
| 30 |
COPY index.html .
|
| 31 |
-
|
| 32 |
|
| 33 |
# Set environment variables
|
| 34 |
ENV HF_HOME=/app/cache/huggingface
|
|
@@ -55,3 +55,4 @@ EXPOSE 8000
|
|
| 55 |
# Use a startup script with debug output
|
| 56 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000", "--log-level", "debug"]
|
| 57 |
|
|
|
|
|
|
| 28 |
# Copy application files
|
| 29 |
COPY app.py .
|
| 30 |
COPY index.html .
|
| 31 |
+
COPY api/ ./api/
|
| 32 |
|
| 33 |
# Set environment variables
|
| 34 |
ENV HF_HOME=/app/cache/huggingface
|
|
|
|
| 55 |
# Use a startup script with debug output
|
| 56 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000", "--log-level", "debug"]
|
| 57 |
|
| 58 |
+
|
app.py
CHANGED
|
@@ -9,7 +9,10 @@ from fastapi import FastAPI
|
|
| 9 |
from fastapi.responses import HTMLResponse
|
| 10 |
from fastapi.staticfiles import StaticFiles
|
| 11 |
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
# Import our main application
|
| 15 |
from api.fastapi_server import app as fastapi_app
|
|
|
|
| 9 |
from fastapi.responses import HTMLResponse
|
| 10 |
from fastapi.staticfiles import StaticFiles
|
| 11 |
|
| 12 |
+
# Add project root to Python path
|
| 13 |
+
current_dir = os.path.abspath(os.path.dirname(__file__))
|
| 14 |
+
if current_dir not in sys.path:
|
| 15 |
+
sys.path.insert(0, current_dir)
|
| 16 |
|
| 17 |
# Import our main application
|
| 18 |
from api.fastapi_server import app as fastapi_app
|