FROM python:3.10-slim WORKDIR /app # System deps RUN apt-get update && apt-get install -y --no-install-recommends \ poppler-utils \ libpq-dev \ gcc \ tesseract-ocr \ curl \ && rm -rf /var/lib/apt/lists/* # Install Node.js for building frontend RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \ && apt-get install -y nodejs \ && rm -rf /var/lib/apt/lists/* # Install Python deps COPY backend/requirements.txt /app/requirements.txt RUN pip install --no-cache-dir -r /app/requirements.txt # Build frontend COPY frontend/package.json frontend/package-lock.json* /app/frontend/ WORKDIR /app/frontend RUN npm install COPY frontend/ /app/frontend/ RUN npm run build # Copy backend WORKDIR /app COPY backend/ /app/ # Move frontend build AFTER backend copy RUN cp -r /app/frontend/dist /app/static # Create storage directory and set permissions RUN mkdir -p /app/storage/documents && \ useradd -m -u 1000 user && \ chown -R user:user /app USER user EXPOSE 7860 CMD ["sh", "-c", "alembic upgrade head && uvicorn app.main:app --host 0.0.0.0 --port 7860"]