FROM python:3.11-slim # Install system dependencies and Python dependencies in one layer to reduce image size RUN apt-get update && apt-get install -y --no-install-recommends \ curl \ procps \ net-tools \ psmisc \ && rm -rf /var/lib/apt/lists/* WORKDIR /app # Install Python dependencies FIRST to cache this layer # Note: server/requirements.txt is copied to /tmp inside the container COPY server/requirements.txt /tmp/requirements.txt RUN pip install --no-cache-dir -r /tmp/requirements.txt && rm /tmp/requirements.txt # Copy only the necessary code files (changing these won't invalidate the pip layer) COPY models.py client.py __init__.py openenv.yaml /app/ COPY server/ /app/server/ # Set environment ENV PYTHONPATH=/app ENV PYTHONUNBUFFERED=1 # Create workspace RUN mkdir -p /tmp/sre_tasks # Expose the server port EXPOSE 7860 # Run the FastAPI server CMD ["uvicorn", "server.app:app", "--host", "0.0.0.0", "--port", "7860"]