Fix Docker Runtime: Align venv paths and use python -m uvicorn
Browse files- Dockerfile +9 -11
Dockerfile
CHANGED
|
@@ -16,16 +16,14 @@ FROM python:3.11-slim AS python-builder
|
|
| 16 |
|
| 17 |
WORKDIR /build-python
|
| 18 |
|
| 19 |
-
#
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
|
| 24 |
-
# Install
|
| 25 |
COPY requirements.txt .
|
| 26 |
-
RUN
|
| 27 |
-
&& /build-python/venv/bin/pip install --upgrade pip \
|
| 28 |
-
&& /build-python/venv/bin/pip install --no-cache-dir -r requirements.txt
|
| 29 |
|
| 30 |
# ββ Stage 3: Production βββββββββββββββββββββββββββββββββββββββ
|
| 31 |
FROM python:3.11-slim AS production
|
|
@@ -45,7 +43,7 @@ ENV PATH="/app/venv/bin:$PATH"
|
|
| 45 |
ENV PYTHONPATH="/app"
|
| 46 |
|
| 47 |
# Copy virtualenv from builder
|
| 48 |
-
COPY --from=python-builder /
|
| 49 |
|
| 50 |
# Copy dashboard build from frontend-builder
|
| 51 |
# (Vite config builds to ../static/dashboard relative to /src/dashboard)
|
|
@@ -70,5 +68,5 @@ EXPOSE 7860
|
|
| 70 |
HEALTHCHECK --interval=30s --timeout=10s --start-period=15s --retries=3 \
|
| 71 |
CMD curl -f http://localhost:7860/health || exit 1
|
| 72 |
|
| 73 |
-
# Run the application using
|
| 74 |
-
CMD ["
|
|
|
|
| 16 |
|
| 17 |
WORKDIR /build-python
|
| 18 |
|
| 19 |
+
# Environment setup
|
| 20 |
+
WORKDIR /app
|
| 21 |
+
RUN python -m venv /app/venv
|
| 22 |
+
ENV PATH="/app/venv/bin:$PATH"
|
| 23 |
|
| 24 |
+
# Install dependencies in venv
|
| 25 |
COPY requirements.txt .
|
| 26 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
|
|
|
| 27 |
|
| 28 |
# ββ Stage 3: Production βββββββββββββββββββββββββββββββββββββββ
|
| 29 |
FROM python:3.11-slim AS production
|
|
|
|
| 43 |
ENV PYTHONPATH="/app"
|
| 44 |
|
| 45 |
# Copy virtualenv from builder
|
| 46 |
+
COPY --from=python-builder /app/venv /app/venv
|
| 47 |
|
| 48 |
# Copy dashboard build from frontend-builder
|
| 49 |
# (Vite config builds to ../static/dashboard relative to /src/dashboard)
|
|
|
|
| 68 |
HEALTHCHECK --interval=30s --timeout=10s --start-period=15s --retries=3 \
|
| 69 |
CMD curl -f http://localhost:7860/health || exit 1
|
| 70 |
|
| 71 |
+
# Run the application using python -m for maximum portability
|
| 72 |
+
CMD ["python", "-m", "uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]
|