| # Use an official Python runtime as the base image | |
| FROM python:3.9-slim | |
| # Set the working directory in the container | |
| WORKDIR /app | |
| # Copy the application files to the container | |
| COPY app.py . | |
| COPY templates/ ./templates/ | |
| COPY model.pkl . | |
| COPY vectorizer.pkl . | |
| # Copy the requirements file and install dependencies | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Download NLTK data (stopwords, punkt) to a specific directory | |
| RUN mkdir -p /app/nltk_data && \ | |
| python3 -m nltk.downloader -d /app/nltk_data stopwords punkt | |
| # Set the NLTK_DATA environment variable to use the downloaded data | |
| ENV NLTK_DATA=/app/nltk_data | |
| # Expose the port the app will run on | |
| EXPOSE 7860 | |
| # Command to run the application | |
| CMD ["python", "app.py"] | |