# Use Python 3.9 as the base image FROM python:3.11-slim # Set working directory WORKDIR /app # Install system dependencies RUN apt-get update && \ apt-get install -y --no-install-recommends \ build-essential \ python3-dev \ && rm -rf /var/lib/apt/lists/* # Create and activate virtual environment ENV VIRTUAL_ENV=/opt/venv RUN python3 -m venv $VIRTUAL_ENV ENV PATH="$VIRTUAL_ENV/bin:$PATH" # Copy requirements first to leverage Docker cache COPY requirements.txt /app/requirements.txt # Install dependencies in virtual environment RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt RUN pip install -qU chainlit # Copy the rest of the application COPY . . # Expose the default Chainlit port EXPOSE 7860 CMD ["chainlit", "run", "app.py", "--port", "7860"]