Spaces:
Sleeping
Sleeping
File size: 1,331 Bytes
7aec7b3 a0697c8 7aec7b3 a0697c8 7aec7b3 a0697c8 7aec7b3 dbea75b 7aec7b3 a0697c8 7aec7b3 b53d446 7aec7b3 |
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 |
# Use an official Python runtime as a parent image
FROM python:3.10-slim
# Install system dependencies (poppler-utils and tesseract-ocr)
RUN apt-get update && apt-get install -y \
poppler-utils \
tesseract-ocr \
libtesseract-dev \
&& rm -rf /var/lib/apt/lists/*
# Create a non-root user
RUN useradd -m appuser
# Set working directory
WORKDIR /app
# Copy requirements.txt and install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy the app code and templates
COPY app.py .
COPY templates /app/templates/
# If you add a static folder in the future for CSS/JS:
# COPY static /app/static/
# Switch to non-root user
USER appuser
# Expose the port the app runs on (for documentation, HF handles actual mapping)
# Gunicorn will bind to this port. Hugging Face Spaces typically expect apps on 7860.
EXPOSE 7860
# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV FLASK_APP=app.py
# Recommended: Set FLASK_ENV to production for real deployments,
# but gunicorn handles this role better than Flask dev server.
# ENV FLASK_ENV=production
# Run the Flask app with Gunicorn
# The 'app:app' means Gunicorn should look for an object named 'app' in a file named 'app.py'.
CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "2", "--timeout", "120", "app:app"] |