MISSAOUI commited on
Commit
9b5a46a
Β·
verified Β·
1 Parent(s): 75e5fc2

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +21 -15
Dockerfile CHANGED
@@ -1,22 +1,28 @@
1
- FROM python:3.10-slim
 
2
 
3
- WORKDIR /app
 
 
4
 
5
- # System deps (important for FAISS + HF embeddings)
6
- RUN apt-get update && apt-get install -y \
7
- build-essential \
8
- git \
9
- && rm -rf /var/lib/apt/lists/*
10
 
11
- # Install Python deps
12
- COPY requirements.txt .
13
- RUN pip install --no-cache-dir -r requirements.txt
14
 
15
- # Copy app
16
- COPY . .
 
 
17
 
18
- # HF Spaces uses port 7860
 
 
 
 
19
  EXPOSE 7860
20
 
21
- # Start FastAPI with uvicorn
22
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ # ── Base image ────────────────────────────────────────────────────────────────
2
+ FROM python:3.11-slim
3
 
4
+ # HuggingFace Spaces runs as a non-root user (UID 1000)
5
+ RUN useradd -m -u 1000 user
6
+ USER user
7
 
8
+ ENV HOME=/home/user \
9
+ PATH=/home/user/.local/bin:$PATH \
10
+ PYTHONUNBUFFERED=1 \
11
+ PYTHONDONTWRITEBYTECODE=1
 
12
 
13
+ WORKDIR $HOME/app
 
 
14
 
15
+ # ── Install dependencies ───────────────────────────────────────────────────────
16
+ COPY --chown=user requirements.txt .
17
+ RUN pip install --no-cache-dir --upgrade pip && \
18
+ pip install --no-cache-dir -r requirements.txt
19
 
20
+ # ── Copy application files ────────────────────────────────────────────────────
21
+ # Make sure faiss_index/, prompt_engineering.py, and main.py are all present
22
+ COPY --chown=user . .
23
+
24
+ # ── Expose port 7860 (required by HuggingFace Spaces) ────────────────────────
25
  EXPOSE 7860
26
 
27
+ # ── Launch ────────────────────────────────────────────────────────────────────
28
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]