# Base image | |
FROM python:3.12 | |
# Set working directory inside the container | |
WORKDIR /app | |
# Install system dependencies | |
RUN apt-get update && apt-get install -y \ | |
build-essential \ | |
libpoppler-cpp-dev \ | |
wget \ | |
&& apt-get clean \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Install PyTorch (CPU version) | |
RUN pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu | |
# Install Poetry | |
RUN pip install --no-cache-dir poetry | |
# Copy dependency files | |
COPY poetry.lock pyproject.toml /app/ | |
# Configure Poetry | |
RUN poetry config virtualenvs.create false | |
# Install project dependencies using Poetry | |
RUN poetry install --no-root --no-dev | |
# Copy the rest of the project files | |
COPY . /app/ | |
# Set environment variables | |
ENV PYTHONPATH=/app/src | |
ENV TOKENIZERS_PARALLELISM=false | |
ENV TORCH_CPP_LOG_LEVEL=ERROR | |
ENV PYTORCH_DISABLE_SYSTEM_MONITORING=1 | |
# Set writable cache directory for Hugging Face | |
ENV HF_HOME=/app/cache | |
# Create and set permissions for the cache directory | |
RUN mkdir -p /app/cache && chmod -R 777 /app/cache | |
# Expose the app's default port | |
EXPOSE 7860 | |
# Command to start the Gradio app | |
CMD ["python3", "app.py"] | |