kab-ocr-tanti / Dockerfile
AitBAD's picture
Update Dockerfile
6d72288 verified
# Use a base image that supports Python and is suitable for Streamlit
FROM python:3.10-slim
# Install Tesseract and Poppler (required by pdf2image) using apt-get
RUN apt-get update && apt-get install -y \
tesseract-ocr \
libtesseract-dev \
poppler-utils \
&& rm -rf /var/lib/apt/lists/*
# Copy your requirements file first (for better caching)
COPY requirements.txt .
# Install Python dependencies, including streamlit
RUN pip install --no-cache-dir -r requirements.txt
# Set the working directory inside the container
WORKDIR /app
# Copy the rest of your application code (including app.py, tessdata/, etc.)
COPY . .
# Create Streamlit config to fix 403 error
RUN mkdir -p ~/.streamlit && \
echo "[server]\n\
headless = true\n\
enableCORS = false\n\
enableXsrfProtection = false\n\
maxUploadSize = 200\n\
port = 7860\n\
address = \"0.0.0.0\"\n\
\n\
[browser]\n\
gatherUsageStats = false\n\
" > ~/.streamlit/config.toml
# Expose the port for Hugging Face Spaces (must be 7860)
EXPOSE 7860
# Define the command to run your Streamlit app
CMD ["streamlit", "run", "app.py", \
"--server.port=7860", \
"--server.address=0.0.0.0", \
"--server.enableCORS=false", \
"--server.enableXsrfProtection=false"]