acpcchatbotadmin commited on
Commit
37113c2
·
verified ·
1 Parent(s): a3a2112

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +7 -11
Dockerfile CHANGED
@@ -4,29 +4,25 @@ FROM python:3.11-slim AS builder
4
  WORKDIR /app
5
  COPY requirements.txt .
6
 
7
- RUN pip install --user --no-cache-dir -r requirements.txt
 
8
 
9
  # Stage 2: Runtime
10
  FROM python:3.11-slim AS runtime
11
 
12
  WORKDIR /app
13
 
14
- # Copy installed packages from builder
15
- COPY --from=builder /root/.local /root/.local
16
- ENV PATH=/root/.local/bin:$PATH
17
 
18
- # Copy application code only (no tests, no eval)
19
  COPY app/ ./app/
20
 
21
- # HF Spaces runs as a non-root user (UID 1000)
22
- # Create the user to match HF's runtime UID
23
  RUN useradd -m -u 1000 user
24
  USER user
25
 
26
- # HF Spaces requires port 7860
27
  EXPOSE 7860
28
 
29
- # Single worker — HF free tier has ~16GB RAM but cold starts are common;
30
- # single worker avoids OOM on smaller hardware tiers.
31
- # Increase --workers to 2 only on upgraded hardware tiers.
32
  CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]
 
4
  WORKDIR /app
5
  COPY requirements.txt .
6
 
7
+ # Install system-wide, not --user
8
+ RUN pip install --no-cache-dir -r requirements.txt
9
 
10
  # Stage 2: Runtime
11
  FROM python:3.11-slim AS runtime
12
 
13
  WORKDIR /app
14
 
15
+ # Copy system-wide site-packages from builder
16
+ COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
17
+ COPY --from=builder /usr/local/bin /usr/local/bin
18
 
19
+ # Copy application code
20
  COPY app/ ./app/
21
 
22
+ # HF Spaces runs as UID 1000
 
23
  RUN useradd -m -u 1000 user
24
  USER user
25
 
 
26
  EXPOSE 7860
27
 
 
 
 
28
  CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]