# Multi-stage Dockerfile: build frontend, run FastAPI backend FROM node:20-alpine AS frontend-builder WORKDIR /app COPY frontend/package.json frontend/package-lock.json* ./ RUN npm ci --no-audit --no-fund || npm install --no-audit --no-fund COPY frontend/ ./ RUN npm run build FROM python:3.11-slim AS backend ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 WORKDIR /app # System deps (faiss-cpu needs libgomp1 on Debian) RUN apt-get update && apt-get install -y --no-install-recommends \ libgomp1 \ && rm -rf /var/lib/apt/lists/* COPY requirements.txt ./ RUN pip install --no-cache-dir -r requirements.txt # Copy application COPY . /app # Copy built frontend into expected path for static serving RUN mkdir -p /app/frontend/dist COPY --from=frontend-builder /app/dist /app/frontend/dist EXPOSE 7860 # Hugging Face Spaces는 기본 PORT=7860을 사용합니다. CMD ["sh", "-c", "uvicorn api_server:app --host 0.0.0.0 --port ${PORT:-7860}"]