FROM python:3.9 # Set environment variables ENV MPLCONFIGDIR /tmp/matplotlib-cache ENV NLTK_DATA /nltk_data ENV FONTCONFIG_PATH=/tmp/fontconfig-cache # Create writable directories RUN mkdir -p /tmp/matplotlib-cache /nltk_data \ && chmod 777 /tmp/matplotlib-cache /nltk_data RUN mkdir -p $FONTCONFIG_PATH && chmod 777 $FONTCONFIG_PATH # Set the working directory WORKDIR / # Copy requirements.txt and install dependencies COPY ./requirements.txt /requirements.txt RUN pip install --no-cache-dir --upgrade -r /requirements.txt # Copy the rest of the application files COPY . . # Expose the required port EXPOSE 7860 # Run the application with Gunicorn CMD ["gunicorn", "-w", "1", "-b", "0.0.0.0:7860", "app:app"]