FROM python:3.9-slim # Install essential tools RUN apt-get update && apt-get install -y \ poppler-utils \ pandoc \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* # Set working directory WORKDIR /app # Copy requirements file first for better caching COPY requirements.txt ./ # Install dependencies RUN pip install --no-cache-dir -r requirements.txt \ && pip install python-multipart uvicorn fastapi pydantic requests jinja2 # Create directories and set permissions RUN mkdir -p /app/frontend \ && mkdir -p /tmp/.matplotlib \ && chmod 777 /tmp/.matplotlib # Set environment variables ENV MPLCONFIGDIR=/tmp/.matplotlib ENV PYTHONUNBUFFERED=1 # Uncomment and set your HF API key if needed # ENV HF_API_KEY=your_huggingface_api_key # Copy application code and static files COPY backend_fastapi.py ./ COPY frontend ./frontend/ # Create requirements.txt if it doesn't exist yet RUN if [ ! -f requirements.txt ]; then \ echo "fastapi==0.103.1\nuvicorn==0.23.2\npython-multipart==0.0.6\nrequests==2.31.0\nJinja2==3.1.2\npydantic==2.4.2" > requirements.txt; \ fi # Expose port EXPOSE 7860 # Start command CMD ["uvicorn", "backend_fastapi:app", "--host", "0.0.0.0", "--port", "7860"]