FROM python:3.11-slim ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 \ NLTK_DATA=/usr/local/nltk_data WORKDIR /app # install deps RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ git \ python3-dev \ libffi-dev \ libssl-dev \ rustc \ cargo \ && rm -rf /var/lib/apt/lists/* # upgrade pip RUN python -m pip install --upgrade pip setuptools wheel # install nltk + required packages before copying app RUN pip install --no-cache-dir nltk # download nltk models inside image (not at runtime) RUN python -m nltk.downloader -d /usr/local/nltk_data punkt averaged_perceptron_tagger averaged_perceptron_tagger_eng # copy requirements and install COPY requirements.txt /app/requirements.txt RUN pip install --no-cache-dir -r /app/requirements.txt # copy app COPY . /app EXPOSE 7860 CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]