FROM python:3.12-slim WORKDIR /app # Python deps (sqlite3 is stdlib — no pip package needed) COPY site/requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy pipeline and data (cache-bust on each deploy) ARG CACHE_BUST=20260816-1527 COPY pipeline/ ./pipeline/ RUN mkdir -p ./data # Copy site (Astro static build) COPY site/ ./site/ # Build Astro static site if dist/ doesn't exist # (build-essential is for better-sqlite3 native Node addon compilation) RUN if [ ! -d site/dist ]; then \ apt-get update && \ apt-get install -y --no-install-recommends build-essential curl && \ curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \ apt-get install -y nodejs && \ cd site && npm install && npm run build && cd .. && \ apt-get remove -y build-essential nodejs && \ apt-get autoremove -y && \ rm -rf /var/lib/apt/lists/*; \ fi # Copy Space entry point COPY space_app.py ./app.py EXPOSE 7860 CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]