FROM python:3.13-slim AS builder # Prevent Python from writing .pyc files and enable unbuffered stdout/stderr ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 \ PIP_DISABLE_PIP_VERSION_CHECK=1 \ PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 WORKDIR /app # Install build deps required to build wheels RUN apt-get update \ && apt-get install -y --no-install-recommends build-essential gcc \ && rm -rf /var/lib/apt/lists/* # Upgrade packaging tools and install runtime dependencies into a separate prefix COPY requirements.txt ./ RUN pip install --upgrade pip setuptools wheel \ && pip install --prefix=/install --no-cache-dir \ --extra-index-url https://git.theprivateserver.de/api/packages/PHB/pypi/simple/ \ -r requirements.txt \ && rm -rf /root/.cache/pip # Copy application source (only used to include app files in final image) COPY . /app FROM python:3.13-slim ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 \ API_PORT=8001 WORKDIR /app # Copy installed packages from the builder image into the final image COPY --from=builder /install /usr/local # Copy application sources COPY --from=builder /app /app EXPOSE 8001 # Run using uvicorn; the app is defined in `api_service.py` as `app` CMD ["uvicorn", "api_service:app", "--host", "0.0.0.0", "--port", "8001"]