| FROM python:3.9-slim | |
| # Install necessary system dependencies | |
| RUN apt-get update && apt-get install -y \ | |
| gcc \ | |
| build-essential \ | |
| libffi-dev \ | |
| libssl-dev \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Create a directory for NLTK data and set permissions | |
| RUN mkdir -p /app/nltk_data && chown -R 1000:1000 /app/nltk_data | |
| RUN mkdir -p /app/plots && chown -R 1000:1000 /app | |
| # Set environment variable for NLTK data | |
| ENV NLTK_DATA=/app/nltk_data | |
| # Set the working directory | |
| WORKDIR /app | |
| # Copy requirements and install dependencies | |
| COPY requirements.txt ./ | |
| RUN pip install --no-cache-dir --upgrade -r requirements.txt | |
| # Copy application code | |
| COPY . . | |
| # Expose port | |
| EXPOSE 7860 | |
| # Command to run the FastAPI application | |
| CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] | |