# ── Stage 1: Build Vue frontend ────────────────────────────────────────────── FROM node:20-alpine AS frontend-build WORKDIR /frontend RUN apk add --no-cache git RUN git clone https://github.com/ICA-PUC/chatbot-norm-frontend.git . RUN npm ci && npm run build # ── Stage 2: Python backend ─────────────────────────────────────────────────── FROM python:3.11-slim ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONUNBUFFERED=1 WORKDIR /app RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ && rm -rf /var/lib/apt/lists/* COPY requirements.txt . RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir -r requirements.txt && \ pip install --no-cache-dir huggingface_hub COPY . . # Descargar el índice FAISS desde HF Dataset # El token HF_TOKEN se inyecta como build-arg para repos privados. # Si el dataset es público, omitir --build-arg HF_TOKEN. ARG HF_TOKEN RUN mkdir -p data/index/intfloat/multilingual-e5-large && \ python - <<'EOF' import os from huggingface_hub import hf_hub_download token = os.getenv("HF_TOKEN") or None repo = "ICA-PUC/norm-index" dest = "data/index/intfloat/multilingual-e5-large" for filename in ["faiss.index", "metadata.jsonl"]: path = hf_hub_download( repo_id=repo, filename=filename, repo_type="dataset", token=token, local_dir=dest, ) print(f"Downloaded: {path}") EOF # Copiar el build del frontend COPY --from=frontend-build /frontend/dist /app/static # Puerto requerido por Hugging Face Spaces ENV PORT=7860 EXPOSE 7860 CMD uvicorn app.main:app --host 0.0.0.0 --port ${PORT}