# Build stage - Python FastAPI application FROM hub.rat.dev/library/python:3.12-slim AS build-stage WORKDIR /app # Install dependencies COPY requirements.txt ./ RUN pip install --no-cache-dir -i https://mirrors.aliyun.com/pypi/simple/ -r requirements.txt # Production stage FROM hub.rat.dev/library/python:3.12-slim AS production-stage WORKDIR /app # Copy installed packages from build stage COPY --from=build-stage /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages COPY --from=build-stage /usr/local/bin /usr/local/bin # Copy application code COPY app ./app EXPOSE 8002 CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8002"]