eReader / Dockerfile
hazardtln's picture
Fresh start: optimized code for Vercel/HF with PWA and Speed Fixes
61b5cbf
# Stage 1: Build the Frontend
FROM node:20-slim AS build-frontend
WORKDIR /frontend
COPY App/frontend/package*.json ./
RUN npm install
COPY App/frontend/ ./
RUN npm run build
# Stage 2: Build the Backend and Serve
FROM python:3.10
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y \
ffmpeg \
libgomp1 \
libsndfile1 \
build-essential \
python3-dev \
&& rm -rf /var/lib/apt/lists/*
# Copy backend requirements and install
COPY requirements_docker.txt ./
RUN pip install --no-cache-dir -r requirements_docker.txt
# Copy backend code (just the download script first for caching)
COPY App/backend/download_model.py ./
RUN python download_model.py
# Copy the rest of the backend code
COPY App/backend/ ./
# Copy built frontend from Stage 1 into the backend's static directory
COPY --from=build-frontend /frontend/dist ./static
# Expose the port (Hugging Face uses 7860 by default)
EXPOSE 7860
# Run the application
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]