Spaces:
Sleeping
Sleeping
| # syntax=docker/dockerfile:1.7 | |
| # ---------- Stage 1: Build the Next.js frontend ---------- | |
| FROM node:20-bookworm-slim AS frontend-build | |
| WORKDIR /app/frontend | |
| COPY frontend/package.json frontend/package-lock.json* ./ | |
| RUN npm install --no-audit --no-fund | |
| COPY frontend/ ./ | |
| ENV NEXT_TELEMETRY_DISABLED=1 | |
| RUN npm run build | |
| # ---------- Stage 2: Runtime (Python 3.13 + Node 20) ---------- | |
| FROM python:3.13-slim-bookworm AS runtime | |
| # Install Node 20 (needed to run `next start`) and minimal system libs | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| curl ca-certificates gnupg build-essential \ | |
| && curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \ | |
| && apt-get install -y --no-install-recommends nodejs \ | |
| && apt-get clean && rm -rf /var/lib/apt/lists/* | |
| # Install uv (fast Python package manager) | |
| RUN pip install --no-cache-dir uv | |
| # HF Spaces requires the working dir to be writable by an arbitrary uid. | |
| # We create /app and chmod it 777 so cache + lancedb dirs work at runtime. | |
| WORKDIR /app | |
| # ---- Backend ---- | |
| COPY backend/pyproject.toml backend/uv.lock* ./backend/ | |
| RUN cd backend && uv sync --no-dev --frozen 2>/dev/null || (cd backend && uv sync --no-dev) | |
| COPY backend/ ./backend/ | |
| # ---- Frontend (built artifacts only) ---- | |
| COPY --from=frontend-build /app/frontend/.next ./frontend/.next | |
| COPY --from=frontend-build /app/frontend/public ./frontend/public | |
| COPY --from=frontend-build /app/frontend/package.json ./frontend/package.json | |
| COPY --from=frontend-build /app/frontend/next.config.js ./frontend/next.config.js | |
| COPY --from=frontend-build /app/frontend/node_modules ./frontend/node_modules | |
| # ---- Entry script ---- | |
| COPY start.sh /app/start.sh | |
| RUN chmod +x /app/start.sh | |
| # Cache + data dirs (HF Spaces runs as random uid; make them world-writable) | |
| RUN mkdir -p /app/.cache /app/.lancedb /app/.tmp_uploads \ | |
| && chmod -R 777 /app | |
| ENV HF_HOME=/app/.cache \ | |
| LANCEDB_PATH=/app/.lancedb \ | |
| TMP_UPLOAD_DIR=/app/.tmp_uploads \ | |
| BACKEND_PORT=8000 \ | |
| BACKEND_INTERNAL_URL=http://127.0.0.1:8000 \ | |
| FRONTEND_PORT=7860 \ | |
| NEXT_TELEMETRY_DISABLED=1 \ | |
| PYTHONUNBUFFERED=1 | |
| EXPOSE 7860 | |
| CMD ["/app/start.sh"] | |