Spaces:
Runtime error
Runtime error
File size: 2,203 Bytes
169aba7 | 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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | # ============================================================
# Math Search Engine โ Hugging Face Spaces (Gradio SDK)
#
# This runs as a Python app. The React frontend is pre-built
# and served as static files from FastAPI.
# ============================================================
FROM python:3.11-slim
# Install Node.js for building React frontend
RUN apt-get update && \
apt-get install -y --no-install-recommends curl && \
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/*
# Create non-root user (required by HF Spaces)
RUN useradd -m -u 1000 appuser
WORKDIR /app
# โโ Python backend dependencies โโโโโโโโโโโโโโโโโโโโโโโโโโโโ
COPY Backend/requirements.txt /app/Backend/requirements.txt
RUN pip install --no-cache-dir -r /app/Backend/requirements.txt
# Download NLTK data
RUN python -c "import nltk; nltk.download('punkt'); nltk.download('punkt_tab'); nltk.download('wordnet'); nltk.download('stopwords'); nltk.download('omw-1.4')"
# โโ Build React frontend โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
COPY Frontend/package.json Frontend/package-lock.json /app/Frontend/
RUN cd /app/Frontend && npm ci
COPY Frontend/ /app/Frontend/
RUN cd /app/Frontend && npm run build
# Clean up node_modules to save image size (~200 MB)
RUN rm -rf /app/Frontend/node_modules
# โโ Copy backend source โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
COPY Backend/ /app/Backend/
# โโ Copy datasets โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
COPY Documents/ /app/Documents/
# โโ Copy entry point โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
COPY app.py /app/app.py
# Give appuser ownership
RUN chown -R appuser:appuser /app
USER appuser
# HF Spaces expects port 7860
EXPOSE 7860
CMD ["python", "app.py"]
|