62 lines
1.5 KiB
Docker
62 lines
1.5 KiB
Docker
# Stage 1: Build the frontend
|
|
FROM node:16-alpine AS frontend-build
|
|
WORKDIR /app/frontend
|
|
COPY frontend/package.json frontend/package-lock.json* ./
|
|
RUN npm install
|
|
COPY frontend/ .
|
|
RUN npm run build
|
|
|
|
# Stage 2: Build the backend
|
|
FROM python:3.9-slim
|
|
WORKDIR /app
|
|
|
|
# Install system dependencies
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
build-essential \
|
|
poppler-utils \
|
|
tesseract-ocr \
|
|
ghostscript \
|
|
qpdf \
|
|
unpaper \
|
|
libxml2 \
|
|
libxslt1.1 \
|
|
libffi-dev \
|
|
libssl-dev \
|
|
pkg-config \
|
|
python3-dev \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Configure pip for better reliability
|
|
RUN pip config set global.timeout 1000 && \
|
|
pip config set global.retries 10 && \
|
|
pip config set global.default-timeout 1000
|
|
|
|
# Install core dependencies first
|
|
RUN pip install --no-cache-dir \
|
|
Flask==2.3.3 \
|
|
Flask-Login==0.6.3 \
|
|
flask-cors==4.0.0 \
|
|
bcrypt==4.1.2 \
|
|
Pillow==10.0.0 \
|
|
pytesseract==0.3.10
|
|
|
|
# Install OCRmyPDF and its dependencies
|
|
RUN pip install --no-cache-dir ocrmypdf==14.4.0 pdf2image==1.16.3
|
|
|
|
# Install AI-related dependencies
|
|
RUN pip install --no-cache-dir \
|
|
google-generativeai==0.3.1 \
|
|
openai==1.3.0 \
|
|
mistralai==0.0.7
|
|
|
|
# Copy backend code
|
|
COPY backend/ /app/backend/
|
|
|
|
# Copy built frontend assets into the backend's static folder
|
|
COPY --from=frontend-build /app/frontend/build/ /app/backend/static/
|
|
|
|
# Set working directory to backend
|
|
WORKDIR /app/backend
|
|
|
|
EXPOSE 5015
|
|
CMD ["python", "app.py"]
|