From 63394c0ce727c2c8de81923f54bb8df27da9fc45 Mon Sep 17 00:00:00 2001 From: WorldTeacher Date: Tue, 25 Nov 2025 05:13:05 +0100 Subject: [PATCH] change dockerfile --- Dockerfile | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index dbdc321..fae939f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,29 +1,42 @@ -FROM python:3.13-slim +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 won't be installed for actual browser automation PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 WORKDIR /app -# Install build deps (some packages may need them to compile wheels) +# 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 +# Upgrade packaging tools and install runtime dependencies into a separate prefix COPY requirements.txt ./ -RUN pip install --no-cache-dir \ +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 && \ - # Clean up pip cache - rm -rf /root/.cache/pip -# Copy application source + -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`