acpcchatbotadmin commited on
Commit
504d13c
·
verified ·
1 Parent(s): ddbab5c

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +32 -0
Dockerfile ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Stage 1: Build dependencies
2
+ FROM python:3.11-slim AS builder
3
+
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"]