quran-validator / Dockerfile
NightPrince's picture
Initial commit: Quran Recitation Validator v2.2.0
cd7dcf2
# ╔══════════════════════════════════════════════════════════════╗
# β•‘ Quran Recitation Validator β€” Multi-stage Docker build β•‘
# β•‘ Stage 1 : Build React frontend (Node) β•‘
# β•‘ Stage 2 : Run FastAPI server (Python slim) β•‘
# β•‘ Port : 7860 (HuggingFace Spaces compatible) β•‘
# β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
# ── Stage 1: Build React ─────────────────────────────────────────────────────
FROM node:20-alpine AS frontend-builder
WORKDIR /build
# Install deps first (layer cache)
COPY frontend/package.json ./
RUN npm install --silent
# Copy source and build
COPY frontend/ ./
RUN npm run build
# β†’ produces /build/dist/
# ── Stage 2: Python runtime ───────────────────────────────────────────────────
FROM python:3.11-slim
# Non-root user (HuggingFace Spaces requirement)
RUN useradd -m -u 1000 appuser
WORKDIR /app
# Install Python deps (layer cache before copying app code)
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy Python source
COPY *.py ./
# Copy Quran data
COPY data/ ./data/
# Copy built React app from stage 1
COPY --from=frontend-builder /build/dist ./frontend/dist/
# Set ownership
RUN chown -R appuser:appuser /app
USER appuser
# HuggingFace Spaces requires port 7860
EXPOSE 7860
ENV PYTHONUNBUFFERED=1
CMD ["python", "-m", "uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]