ArshVerma commited on
Commit
b66e905
Β·
1 Parent(s): 008e2f6

Fix Docker Runtime: Align venv paths and use python -m uvicorn

Browse files
Files changed (1) hide show
  1. Dockerfile +9 -11
Dockerfile CHANGED
@@ -16,16 +16,14 @@ FROM python:3.11-slim AS python-builder
16
 
17
  WORKDIR /build-python
18
 
19
- # Install build dependencies
20
- RUN apt-get update && apt-get install -y --no-install-recommends \
21
- build-essential \
22
- && rm -rf /var/lib/apt/lists/*
23
 
24
- # Install Python dependencies into /build-python/venv
25
  COPY requirements.txt .
26
- RUN python -m venv /build-python/venv \
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 /build-python/venv /app/venv
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 the venv's uvicorn
74
- CMD ["/app/venv/bin/uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]
 
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"]