Skip to content

ITEP-81653: Reduce cluster analytics runtime image size#592

Merged
saratpoluri merged 9 commits intorelease-2025.2from
fix/ITEP-81653-reduce-cluster-service-image-size
Nov 18, 2025
Merged

ITEP-81653: Reduce cluster analytics runtime image size#592
saratpoluri merged 9 commits intorelease-2025.2from
fix/ITEP-81653-reduce-cluster-service-image-size

Conversation

@daddo-intel
Copy link
Copy Markdown
Contributor

📝 Description

Provide a clear summary of the changes and the context behind them. Describe what was changed, why it was needed, and how the changes address the issue or add value.

✨ Type of Change

Select the type of change your PR introduces:

  • 🐞 Bug fix – Non-breaking change which fixes an issue
  • 🚀 New feature – Non-breaking change which adds functionality
  • 🔨 Refactor – Non-breaking change which refactors the code base
  • 💥 Breaking change – Changes that break existing functionality
  • 📚 Documentation update
  • 🔒 Security update
  • 🧪 Tests
  • 🚂 CI

🧪 Testing Scenarios

Describe how the changes were tested and how reviewers can test them too:

  • ✅ Tested manually
  • 🤖 Ran automated end-to-end tests

✅ Checklist

Before submitting the PR, ensure the following:

  • 🔍 PR title is clear and descriptive
  • 📝 For internal contributors: If applicable, include the JIRA ticket number (e.g., ITEP-123456) in the PR title. Do not include full URLs
  • 💬 I have commented my code, especially in hard-to-understand areas
  • 📄 I have made corresponding changes to the documentation
  • ✅ I have added tests that prove my fix is effective or my feature works


# -------------- Cluster Analytics Runtime Stage --------------
FROM scenescape-common-base-24-04 AS scenescape-cluster-analytics-runtime
FROM python:3.12-slim AS scenescape-cluster-analytics-runtime

Check warning

Code scanning / Scorecard

Pinned-Dependencies Medium

score is 3: containerImage not pinned by hash
Remediation tip: pin your Docker image by updating python:3.12-slim to python:3.12-slim@sha256:a75662dfec8d90bd7161c91050be2e0a9b21d284f3b7a7253d5db25f7d583fb3
Click Remediation section below for further remediation help
ENV PATH="$BUILD_ENV_DIR/bin:$PATH"

# Install core Python dependencies
RUN pip install --no-cache-dir --upgrade pip numpy opencv-python-headless==4.6.0.66

Check warning

Code scanning / Scorecard

Pinned-Dependencies Medium

score is 3: pipCommand not pinned by hash
Click Remediation section below to solve this issue
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR reduces the cluster analytics runtime image size by switching from a custom base image (scenescape-common-base-24-04) to the official python:3.12-slim image and implementing a multi-stage build optimization strategy.

Key Changes:

  • Replaced custom base image with python:3.12-slim for the runtime stage
  • Reorganized dependency installation to use a virtual environment (/opt/venv) instead of system packages
  • Streamlined system dependencies to only essential runtime libraries (libgl1, libglib2.0-0)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

COPY --chown=$USER_ID:$GROUP_ID --from=scenescape-common-base-24-04 /tmp/tools/waitforbroker $SCENESCAPE_HOME/tools/waitforbroker

USER $USER_ID:$GROUP_ID
HEALTHCHECK CMD true
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The healthcheck always returns success (true), making it ineffective. Replace with an actual health check that verifies the service is functioning correctly, such as checking if the application responds to requests or a specific health endpoint.

Suggested change
HEALTHCHECK CMD true
HEALTHCHECK CMD curl --fail --silent http://localhost:8000/health || exit 1

Copilot uses AI. Check for mistakes.
Comment on lines +75 to +83
# Install core Python dependencies
RUN pip install --no-cache-dir --upgrade pip numpy opencv-python-headless==4.6.0.66

# Copy compiled scene_common + fast_geometry from builder
COPY --chown=$WSUSER:$WSUSER --from=scenescape-common-base-24-04 /usr/local/lib/python3.12/dist-packages/scene_common \
$BUILD_ENV_DIR/lib/python3.12/site-packages/scene_common

COPY --chown=$WSUSER:$WSUSER --from=scenescape-common-base-24-04 /usr/local/lib/python3.12/dist-packages/fast_geometry \
$BUILD_ENV_DIR/lib/python3.12/site-packages/fast_geometry
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Python version 3.12 is hardcoded in the path. Since the base image is python:3.12-slim, consider using a variable or dynamic path to make future Python version updates easier.

Suggested change
# Install core Python dependencies
RUN pip install --no-cache-dir --upgrade pip numpy opencv-python-headless==4.6.0.66
# Copy compiled scene_common + fast_geometry from builder
COPY --chown=$WSUSER:$WSUSER --from=scenescape-common-base-24-04 /usr/local/lib/python3.12/dist-packages/scene_common \
$BUILD_ENV_DIR/lib/python3.12/site-packages/scene_common
COPY --chown=$WSUSER:$WSUSER --from=scenescape-common-base-24-04 /usr/local/lib/python3.12/dist-packages/fast_geometry \
$BUILD_ENV_DIR/lib/python3.12/site-packages/fast_geometry
# Dynamically determine Python version (major.minor)
ENV PYTHON_VERSION=$(python3 -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')")
# Install core Python dependencies
RUN pip install --no-cache-dir --upgrade pip numpy opencv-python-headless==4.6.0.66
# Copy compiled scene_common + fast_geometry from builder
COPY --chown=$WSUSER:$WSUSER --from=scenescape-common-base-24-04 /usr/local/lib/${PYTHON_VERSION}/dist-packages/scene_common \
$BUILD_ENV_DIR/lib/${PYTHON_VERSION}/site-packages/scene_common
COPY --chown=$WSUSER:$WSUSER --from=scenescape-common-base-24-04 /usr/local/lib/${PYTHON_VERSION}/dist-packages/fast_geometry \
$BUILD_ENV_DIR/lib/${PYTHON_VERSION}/site-packages/fast_geometry

Copilot uses AI. Check for mistakes.
Comment on lines +82 to +83
COPY --chown=$WSUSER:$WSUSER --from=scenescape-common-base-24-04 /usr/local/lib/python3.12/dist-packages/fast_geometry \
$BUILD_ENV_DIR/lib/python3.12/site-packages/fast_geometry
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Python version 3.12 is hardcoded in the path. Since the base image is python:3.12-slim, consider using a variable or dynamic path to make future Python version updates easier.

Copilot uses AI. Check for mistakes.
@saratpoluri saratpoluri enabled auto-merge (squash) November 18, 2025 06:04
@saratpoluri saratpoluri disabled auto-merge November 18, 2025 07:49
@saratpoluri saratpoluri enabled auto-merge (squash) November 18, 2025 08:24
@saratpoluri saratpoluri merged commit e7db591 into release-2025.2 Nov 18, 2025
25 checks passed
@saratpoluri saratpoluri deleted the fix/ITEP-81653-reduce-cluster-service-image-size branch November 18, 2025 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants