Spaces:
Runtime error
Runtime error
| FROM python:3.10-slim as builder | |
| WORKDIR /app | |
| # Install build dependencies and runtime dependencies | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| build-essential \ | |
| gcc \ | |
| g++ \ | |
| libgl1 \ | |
| libglib2.0-0 \ | |
| python3-dev \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy requirements file | |
| COPY requirements.txt . | |
| # Install dependencies | |
| RUN pip install --no-cache-dir --upgrade pip && \ | |
| pip install --no-cache-dir -r requirements.txt | |
| # pip install --no-cache-dir --prefix=/install -r requirements.txt | |
| # pip install --no-cache-dir --user -r requirements.txt | |
| # Second stage: runtime image | |
| FROM python:3.10-slim | |
| WORKDIR /app | |
| # Install runtime dependencies | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| libgl1 \ | |
| libglib2.0-0 \ | |
| poppler-utils \ | |
| tesseract-ocr \ | |
| # libreoffice \ | |
| libtesseract5 \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # --- Test on HFSpace --- | |
| # Copy requirements file | |
| COPY requirements.txt . | |
| # Install dependencies | |
| RUN pip install --no-cache-dir --upgrade pip && \ | |
| pip install --no-cache-dir -r requirements.txt | |
| # pip install --no-cache-dir --user -r requirements.txt | |
| # --- | |
| # Copy the installed packages from the builder stage | |
| # COPY --from=builder /root/.local /root/.local | |
| # Make sure scripts in .local are usable: | |
| ENV PATH=/root/.local/bin:$PATH | |
| # Copy application code | |
| COPY . . | |
| # Create necessary directories | |
| RUN mkdir -p /app/data/temp | |
| # Set environment variables | |
| ENV PYTHONDONTWRITEBYTECODE=1 \ | |
| PYTHONUNBUFFERED=1 \ | |
| PORT=8000 | |
| # Expose the port | |
| EXPOSE 8000 | |
| # Set a non-root user | |
| RUN useradd -m appuser | |
| RUN chown -R appuser:appuser /app | |
| USER appuser | |
| # Run the application | |
| CMD ["python", "app.py"] | |