saifisvibin's picture
Configure for Hugging Face Spaces deployment with Docker
530365a
# Multi-stage build for Certificate Generator App
# Stage 1: Build the React frontend
FROM node:18-slim as frontend-builder
WORKDIR /app/frontend
# Copy frontend package files
COPY frontend/package*.json ./
# Install dependencies
RUN npm ci
# Copy frontend source
COPY frontend/ ./
# Build the frontend
RUN npm run build
# Stage 2: Setup Python backend and serve the app
FROM python:3.11-slim
WORKDIR /app
# Install system dependencies for PyMuPDF
RUN apt-get update && apt-get install -y \
libmupdf-dev \
mupdf-tools \
&& rm -rf /var/lib/apt/lists/*
# Copy backend requirements
COPY requirements.txt .
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Copy backend code
COPY backend/ ./backend/
# Copy built frontend from previous stage
COPY --from=frontend-builder /app/frontend/dist ./frontend/dist
# Create necessary directories
RUN mkdir -p uploads output
# Expose Hugging Face Spaces port
EXPOSE 7860
# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV PORT=7860
# Run the application
CMD ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "7860"]