refactor: slim image with proper multi-stage build and --no-dev deps
- Dockerfile: separate runtime stage from build stage so g++, python3.12-dev, curl, gnupg are excluded from the final image - uv sync --no-dev: drop ruff/pytest from production image - Remove build.sh (replaced by CI) and root-level upload_tracker.py (stale duplicate) - .gitignore: add *.log Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+23
-7
@@ -16,14 +16,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
ca-certificates \
|
||||
curl \
|
||||
gnupg \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
software-properties-common \
|
||||
&& add-apt-repository ppa:deadsnakes/ppa -y \
|
||||
&& apt-get update && apt-get install -y --no-install-recommends \
|
||||
python3.12 python3.12-venv python3.12-dev \
|
||||
libgl1 libglib2.0-0 libxext6 g++ tini \
|
||||
libgl1 libglib2.0-0 libxext6 g++ \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& ln -sf /usr/bin/python3.12 /usr/bin/python3
|
||||
|
||||
@@ -33,7 +30,7 @@ RUN curl -LsSf https://astral.sh/uv/install.sh | sh \
|
||||
WORKDIR /app
|
||||
|
||||
COPY pyproject.toml uv.lock ./
|
||||
RUN uv sync --frozen \
|
||||
RUN uv sync --frozen --no-dev \
|
||||
&& uv cache clean
|
||||
|
||||
COPY if_curator/ if_curator/
|
||||
@@ -41,7 +38,27 @@ COPY entrypoint.sh scheduler.py ./
|
||||
RUN chmod +x /app/entrypoint.sh
|
||||
|
||||
# ── Runtime stage ─────────────────────────────────────────────────────────
|
||||
FROM build AS runtime
|
||||
# Starts fresh from the base image — excludes build tools (g++,
|
||||
# python3.12-dev, curl, gnupg) that are not needed at runtime.
|
||||
|
||||
FROM base-${TARGETARCH} AS runtime
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
ca-certificates \
|
||||
software-properties-common \
|
||||
tini \
|
||||
&& add-apt-repository ppa:deadsnakes/ppa -y \
|
||||
&& apt-get update && apt-get install -y --no-install-recommends \
|
||||
python3.12 python3.12-venv \
|
||||
libgl1 libglib2.0-0 libxext6 \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& ln -sf /usr/bin/python3.12 /usr/bin/python3
|
||||
|
||||
# Copy app (with .venv) and uv from build stage
|
||||
COPY --from=build /app /app
|
||||
COPY --from=build /usr/local/bin/uv /usr/local/bin/uv
|
||||
|
||||
# Expose CUDA/cuDNN libraries from pip packages so onnxruntime-gpu
|
||||
# can find libcublasLt.so.12 and libcudnn.so.9 at runtime
|
||||
@@ -56,4 +73,3 @@ ENV HF_HOME=/models/huggingface INSIGHTFACE_HOME=/models
|
||||
|
||||
HEALTHCHECK CMD test -f /app/entrypoint.sh || exit 1
|
||||
ENTRYPOINT ["tini", "--", "/app/entrypoint.sh"]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user