Unverified Commit 9f01dd25 authored by Ran Rubin's avatar Ran Rubin Committed by GitHub
Browse files

chore: multi-arch frontend image (#7290)

parent 57648c19
...@@ -84,6 +84,13 @@ runs: ...@@ -84,6 +84,13 @@ runs:
IMAGE_TAG="${{ inputs.image_tag }}" IMAGE_TAG="${{ inputs.image_tag }}"
# Normalize platform: prepend linux/ only when not already present
PLATFORM_FLAG="${PLATFORM}"
if [[ "$PLATFORM_FLAG" != linux/* ]]; then
PLATFORM_FLAG="linux/${PLATFORM_FLAG}"
fi
# Sanitized platform for registry tags and filenames (no slashes or commas)
PLATFORM_SAFE=$(echo "${PLATFORM}" | sed 's|linux/||g; s/,/-/g')
CUDA_VERSION_MAJOR=${CUDA_VERSION%%.*} CUDA_VERSION_MAJOR=${CUDA_VERSION%%.*}
...@@ -94,7 +101,7 @@ runs: ...@@ -94,7 +101,7 @@ runs:
# Create build logs directory # Create build logs directory
mkdir -p build-logs mkdir -p build-logs
BUILD_LOG_FILE="build-logs/build-${{ inputs.framework }}-${{ inputs.platform }}.log" BUILD_LOG_FILE="build-logs/build-${{ inputs.framework }}-${PLATFORM_SAFE}.log"
echo "BUILD_LOG_FILE=${BUILD_LOG_FILE}" >> $GITHUB_ENV echo "BUILD_LOG_FILE=${BUILD_LOG_FILE}" >> $GITHUB_ENV
echo "📝 Build log will be saved to: ${BUILD_LOG_FILE}" echo "📝 Build log will be saved to: ${BUILD_LOG_FILE}"
...@@ -102,7 +109,7 @@ runs: ...@@ -102,7 +109,7 @@ runs:
# Set base cache args and set --cache-to if this is a main commit # Set base cache args and set --cache-to if this is a main commit
CACHE_ARGS="" CACHE_ARGS=""
if [[ "${{ inputs.target }}" != "frontend" ]]; then if [[ "${{ inputs.target }}" != "frontend" ]]; then
CACHE_TAG="${{ inputs.framework }}-cuda${CUDA_VERSION_MAJOR}-${PLATFORM}-cache" CACHE_TAG="${{ inputs.framework }}-cuda${CUDA_VERSION_MAJOR}-${PLATFORM_SAFE}-cache"
CACHE_ARGS="--cache-from type=registry,ref=${ECR_HOSTNAME}/ai-dynamo/dynamo:main-${CACHE_TAG} " CACHE_ARGS="--cache-from type=registry,ref=${ECR_HOSTNAME}/ai-dynamo/dynamo:main-${CACHE_TAG} "
CACHE_ARGS+="--cache-from type=registry,ref=${ECR_HOSTNAME}/ai-dynamo/dynamo:release-${CACHE_TAG} " CACHE_ARGS+="--cache-from type=registry,ref=${ECR_HOSTNAME}/ai-dynamo/dynamo:release-${CACHE_TAG} "
if [[ "$GITHUB_REF_NAME" =~ ^release ]]; then if [[ "$GITHUB_REF_NAME" =~ ^release ]]; then
...@@ -112,7 +119,7 @@ runs: ...@@ -112,7 +119,7 @@ runs:
CACHE_ARGS+="--cache-to type=registry,ref=${ECR_HOSTNAME}/ai-dynamo/dynamo:main-${CACHE_TAG},mode=max " CACHE_ARGS+="--cache-to type=registry,ref=${ECR_HOSTNAME}/ai-dynamo/dynamo:main-${CACHE_TAG},mode=max "
fi fi
else else
CACHE_TAG="${{ inputs.target }}-cuda${CUDA_VERSION_MAJOR}-${PLATFORM}-cache" CACHE_TAG="${{ inputs.target }}-cuda${CUDA_VERSION_MAJOR}-${PLATFORM_SAFE}-cache"
CACHE_ARGS="--cache-from type=registry,ref=${ECR_HOSTNAME}/ai-dynamo/dynamo:main-${CACHE_TAG} " CACHE_ARGS="--cache-from type=registry,ref=${ECR_HOSTNAME}/ai-dynamo/dynamo:main-${CACHE_TAG} "
if [[ "$GITHUB_REF_NAME" == "main" ]]; then if [[ "$GITHUB_REF_NAME" == "main" ]]; then
CACHE_ARGS+="--cache-to type=registry,ref=${ECR_HOSTNAME}/ai-dynamo/dynamo:main-${CACHE_TAG},mode=max " CACHE_ARGS+="--cache-to type=registry,ref=${ECR_HOSTNAME}/ai-dynamo/dynamo:main-${CACHE_TAG},mode=max "
...@@ -166,7 +173,7 @@ runs: ...@@ -166,7 +173,7 @@ runs:
docker buildx build \ docker buildx build \
--progress=plain \ --progress=plain \
--tag "$IMAGE_TAG" \ --tag "$IMAGE_TAG" \
--platform linux/${{ inputs.platform }} \ --platform "${PLATFORM_FLAG}" \
-f ./container/rendered.Dockerfile \ -f ./container/rendered.Dockerfile \
$CACHE_ARGS $EXTRA_ARGS $SECRET_ARGS . 2>&1 | tee "${BUILD_LOG_FILE}" $CACHE_ARGS $EXTRA_ARGS $SECRET_ARGS . 2>&1 | tee "${BUILD_LOG_FILE}"
...@@ -236,7 +243,7 @@ runs: ...@@ -236,7 +243,7 @@ runs:
echo "⚠️ No image tag available" echo "⚠️ No image tag available"
fi fi
PLATFORM_ARCH=$(echo "${{ inputs.platform }}" | sed 's/linux\///') PLATFORM_ARCH=$(echo "${{ inputs.platform }}" | sed 's|linux/||g; s/,/-/g')
echo " Architecture: ${PLATFORM_ARCH}" echo " Architecture: ${PLATFORM_ARCH}"
echo "PLATFORM_ARCH=${PLATFORM_ARCH}" >> $GITHUB_ENV echo "PLATFORM_ARCH=${PLATFORM_ARCH}" >> $GITHUB_ENV
JOB_KEY="${{ inputs.framework }}-${PLATFORM_ARCH}" JOB_KEY="${{ inputs.framework }}-${PLATFORM_ARCH}"
......
...@@ -18,7 +18,7 @@ on: ...@@ -18,7 +18,7 @@ on:
type: boolean type: boolean
default: false default: false
image_prefix: image_prefix:
description: 'Optional prefix for image tags (e.g., release-0.9.0). When set, images are also tagged as {prefix}-frontend-{arch}.' description: 'Optional prefix for image tags (e.g., release-0.9.0). When set, images are also tagged as {prefix}-frontend.'
required: false required: false
type: string type: string
default: '' default: ''
...@@ -124,11 +124,9 @@ jobs: ...@@ -124,11 +124,9 @@ jobs:
name: Build Frontend Image name: Build Frontend Image
needs: [changed-files, build-epp-image] needs: [changed-files, build-epp-image]
if: needs.changed-files.outputs.frontend == 'true' || inputs.skip_change_detection == true || startsWith(github.ref_name, 'release/') if: needs.changed-files.outputs.frontend == 'true' || inputs.skip_change_detection == true || startsWith(github.ref_name, 'release/')
strategy:
fail-fast: false
matrix:
arch: [amd64, arm64]
runs-on: prod-builder-v3 runs-on: prod-builder-v3
outputs:
target_tag: ${{ steps.calculate-target-tag.outputs.target_tag }}
env: env:
IMAGE_REGISTRY: ai-dynamo IMAGE_REGISTRY: ai-dynamo
IMAGE_REPOSITORY: dynamo IMAGE_REPOSITORY: dynamo
...@@ -136,6 +134,7 @@ jobs: ...@@ -136,6 +134,7 @@ jobs:
TARGET: frontend TARGET: frontend
CUDA_VERSION: "12.9" CUDA_VERSION: "12.9"
FRAMEWORK: dynamo FRAMEWORK: dynamo
PLATFORM: "linux/amd64,linux/arm64"
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
...@@ -146,7 +145,7 @@ jobs: ...@@ -146,7 +145,7 @@ jobs:
python ./container/render.py \ python ./container/render.py \
--target=${{ env.TARGET }} \ --target=${{ env.TARGET }} \
--framework=${{ env.FRAMEWORK }} \ --framework=${{ env.FRAMEWORK }} \
--platform=${{ matrix.arch }} \ --platform=${{ env.PLATFORM }} \
--cuda-version=${{ env.CUDA_VERSION }} \ --cuda-version=${{ env.CUDA_VERSION }} \
--show-result \ --show-result \
--output-short-filename --output-short-filename
...@@ -155,7 +154,7 @@ jobs: ...@@ -155,7 +154,7 @@ jobs:
shell: bash shell: bash
run: | run: |
ECR_IMAGE_BASE="${{ env.ECR_HOSTNAME }}/${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_REPOSITORY }}" ECR_IMAGE_BASE="${{ env.ECR_HOSTNAME }}/${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_REPOSITORY }}"
TARGET_TAG="${{ github.sha }}-${{ env.TARGET }}-${{ matrix.arch }}" TARGET_TAG="${{ github.sha }}-${{ env.TARGET }}"
echo "ecr_image_base=${ECR_IMAGE_BASE}" >> $GITHUB_OUTPUT echo "ecr_image_base=${ECR_IMAGE_BASE}" >> $GITHUB_OUTPUT
echo "default_target_image_uri=${ECR_IMAGE_BASE}:${TARGET_TAG}" >> $GITHUB_OUTPUT echo "default_target_image_uri=${ECR_IMAGE_BASE}:${TARGET_TAG}" >> $GITHUB_OUTPUT
echo "epp_image_uri=${{ env.ECR_HOSTNAME }}/${{ needs.build-epp-image.outputs.epp_image_ref }}" >> $GITHUB_OUTPUT echo "epp_image_uri=${{ env.ECR_HOSTNAME }}/${{ needs.build-epp-image.outputs.epp_image_ref }}" >> $GITHUB_OUTPUT
...@@ -167,7 +166,7 @@ jobs: ...@@ -167,7 +166,7 @@ jobs:
echo "image_tag: ${{ steps.calculate-target-tag.outputs.default_target_image_uri }}" echo "image_tag: ${{ steps.calculate-target-tag.outputs.default_target_image_uri }}"
echo "framework: ${{ env.FRAMEWORK }}" echo "framework: ${{ env.FRAMEWORK }}"
echo "target: ${{ env.TARGET }}" echo "target: ${{ env.TARGET }}"
echo "platform: ${{ matrix.arch }}" echo "platform: ${{ env.PLATFORM }}"
echo "cuda_version: ${{ env.CUDA_VERSION }}" echo "cuda_version: ${{ env.CUDA_VERSION }}"
echo "extra_tags: ${{ steps.calculate-target-tag.outputs.azure_target_image_uri }}" echo "extra_tags: ${{ steps.calculate-target-tag.outputs.azure_target_image_uri }}"
echo "epp_image_uri: ${{ steps.calculate-target-tag.outputs.epp_image_uri }}" echo "epp_image_uri: ${{ steps.calculate-target-tag.outputs.epp_image_uri }}"
...@@ -185,7 +184,7 @@ jobs: ...@@ -185,7 +184,7 @@ jobs:
with: with:
builder_name: ${{ needs.changed-files.outputs.builder_name }} builder_name: ${{ needs.changed-files.outputs.builder_name }}
flavor: general flavor: general
arch: ${{ matrix.arch }} all_arch: 'true'
- name: Build Frontend Container - name: Build Frontend Container
id: build-image id: build-image
timeout-minutes: 30 timeout-minutes: 30
...@@ -194,7 +193,7 @@ jobs: ...@@ -194,7 +193,7 @@ jobs:
image_tag: ${{ steps.calculate-target-tag.outputs.default_target_image_uri }} image_tag: ${{ steps.calculate-target-tag.outputs.default_target_image_uri }}
framework: ${{ env.FRAMEWORK }} framework: ${{ env.FRAMEWORK }}
target: ${{ env.TARGET }} target: ${{ env.TARGET }}
platform: ${{ matrix.arch }} platform: ${{ env.PLATFORM }}
cuda_version: ${{ env.CUDA_VERSION }} cuda_version: ${{ env.CUDA_VERSION }}
aws_default_region: ${{ secrets.AWS_DEFAULT_REGION }} aws_default_region: ${{ secrets.AWS_DEFAULT_REGION }}
sccache_s3_bucket: ${{ secrets.SCCACHE_S3_BUCKET }} sccache_s3_bucket: ${{ secrets.SCCACHE_S3_BUCKET }}
...@@ -205,15 +204,15 @@ jobs: ...@@ -205,15 +204,15 @@ jobs:
extra_build_args: | extra_build_args: |
EPP_IMAGE=${{ steps.calculate-target-tag.outputs.epp_image_uri }} EPP_IMAGE=${{ steps.calculate-target-tag.outputs.epp_image_uri }}
extra_tags: | extra_tags: |
${{ matrix.arch == 'amd64' && steps.calculate-target-tag.outputs.azure_target_image_uri || '' }} ${{ steps.calculate-target-tag.outputs.azure_target_image_uri }}
${{ github.ref_name == 'main' && format('{0}:main-frontend-{1}', steps.calculate-target-tag.outputs.ecr_image_base, matrix.arch) || '' }} ${{ github.ref_name == 'main' && format('{0}:main-frontend', steps.calculate-target-tag.outputs.ecr_image_base) || '' }}
${{ github.ref_name == 'main' && format('{0}:main-frontend-{1}-{2}', steps.calculate-target-tag.outputs.ecr_image_base, github.sha, matrix.arch) || '' }} ${{ github.ref_name == 'main' && format('{0}:main-frontend-{1}', steps.calculate-target-tag.outputs.ecr_image_base, github.sha) || '' }}
${{ inputs.image_prefix != '' && format('{0}:{1}-frontend-{2}', steps.calculate-target-tag.outputs.ecr_image_base, inputs.image_prefix, matrix.arch) || '' }} ${{ inputs.image_prefix != '' && format('{0}:{1}-frontend', steps.calculate-target-tag.outputs.ecr_image_base, inputs.image_prefix) || '' }}
- name: Show summary - name: Show summary
shell: bash shell: bash
run: | run: |
echo "### 🐳 ${{ env.FRAMEWORK }}-cuda${{ env.CUDA_VERSION }}-${{ matrix.arch }} Default Image" >> $GITHUB_STEP_SUMMARY echo "### Frontend Image (multi-arch)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY
echo "| Image URI |" >> $GITHUB_STEP_SUMMARY echo "| Image URI |" >> $GITHUB_STEP_SUMMARY
echo "|-----|" >> $GITHUB_STEP_SUMMARY echo "|-----|" >> $GITHUB_STEP_SUMMARY
...@@ -229,9 +228,13 @@ jobs: ...@@ -229,9 +228,13 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
arch: [amd64, arm64] include:
- arch: amd64
runner: prod-builder-amd-v1
- arch: arm64
runner: prod-tester-arm-v1
name: Compliance frontend-${{ matrix.arch }} name: Compliance frontend-${{ matrix.arch }}
runs-on: ${{ matrix.arch == 'amd64' && 'prod-builder-amd-v1' || 'prod-tester-arm-v1' }} runs-on: ${{ matrix.runner }}
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
...@@ -243,17 +246,10 @@ jobs: ...@@ -243,17 +246,10 @@ jobs:
azure_acr_hostname: ${{ secrets.AZURE_ACR_HOSTNAME }} azure_acr_hostname: ${{ secrets.AZURE_ACR_HOSTNAME }}
azure_acr_user: ${{ secrets.AZURE_ACR_USER }} azure_acr_user: ${{ secrets.AZURE_ACR_USER }}
azure_acr_password: ${{ secrets.AZURE_ACR_PASSWORD }} azure_acr_password: ${{ secrets.AZURE_ACR_PASSWORD }}
- name: Calculate image URI
id: images
shell: bash
run: |
TARGET_TAG="${{ github.sha }}-frontend-${{ matrix.arch }}"
FRONTEND_IMAGE="${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_DEFAULT_REGION }}.amazonaws.com/ai-dynamo/dynamo:${TARGET_TAG}"
echo "frontend_image=${FRONTEND_IMAGE}" >> $GITHUB_OUTPUT
- name: Compliance scan - name: Compliance scan
uses: ./.github/actions/compliance-scan uses: ./.github/actions/compliance-scan
with: with:
image: ${{ steps.images.outputs.frontend_image }} image: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_DEFAULT_REGION }}.amazonaws.com/ai-dynamo/dynamo:${{ needs.build-frontend-image.outputs.target_tag }}
artifact_name: compliance-frontend-${{ matrix.arch }} artifact_name: compliance-frontend-${{ matrix.arch }}
framework: dynamo framework: dynamo
target: frontend target: frontend
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment