# Use an official lightweight Python image. | |
FROM python:3.10-slim | |
# Install system packages required by some Python dependencies. | |
RUN apt-get update && apt-get install -y --no-install-recommends \ | |
build-essential \ | |
git \ | |
wget \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Set the working directory inside the container. | |
WORKDIR /app | |
# Set environment variables for NLTK and Hugging Face Transformers cache directories. | |
ENV NLTK_DATA=/app/nltk_data | |
ENV TRANSFORMERS_CACHE=/app/transformers_cache | |
# Create the cache directories with permissions that allow writing. | |
RUN mkdir -p /app/nltk_data /app/transformers_cache && \ | |
chmod -R 777 /app/nltk_data /app/transformers_cache | |
# Copy the requirements file and install the Python dependencies. | |
COPY requirements.txt . | |
RUN pip install --upgrade pip && pip install -r requirements.txt | |
# Copy your entire project into the container. | |
COPY . . | |
# Expose the port your Flask app will run on. | |
EXPOSE 7860 | |
# Define the command to run your Flask app. | |
CMD ["python", "app.py"] | |