Spaces:
Sleeping
Sleeping
File size: 1,130 Bytes
530365a | 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 | # 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"]
|