File size: 1,152 Bytes
d992912
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
FROM python:3.11-slim

# System packages needed by PyTorch, FAISS, and Pillow
RUN apt-get update && apt-get install -y --no-install-recommends \
    gcc g++ libgomp1 && \
    rm -rf /var/lib/apt/lists/*

# Install Python dependencies as root so they are globally accessible
COPY backend/requirements.txt /tmp/requirements.txt
RUN pip install --no-cache-dir --upgrade -r /tmp/requirements.txt

# HuggingFace Spaces requires a non-root user with uid=1000
RUN useradd -m -u 1000 user
USER user
ENV PATH="/home/user/.local/bin:$PATH"

WORKDIR /app

# Copy backend Python source
COPY --chown=user backend/ /app/backend/

# Bake the pre-built data into the image.
# This avoids a 3-5 hour FAISS rebuild on free CPU on every cold start.
COPY --chown=user asos_clean.csv /app/data/asos_clean.csv
COPY --chown=user asos_engine/ /app/data/asos_engine/

# Tell the backend where to find its data
ENV PYTHONPATH=/app
ENV ASOS_DATA_PATH=/app/data/asos_clean.csv
ENV ASOS_PERSISTENT_DIR=/app/data/asos_engine
ENV ASOS_LOG_LEVEL=INFO

# HuggingFace Spaces requires port 7860
EXPOSE 7860

CMD ["uvicorn", "backend.app.main:app", "--host", "0.0.0.0", "--port", "7860"]