Skip to content

Splitting arm/amd tags for operator and target allocator #304

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 28, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 113 additions & 16 deletions .github/workflows/build-and-upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ env:
ECR_OPERATOR_RELEASE_IMAGE: ${{ vars.ECR_OPERATOR_RELEASE_IMAGE }}
ECR_TARGET_ALLOCATOR_STAGING_REPO: ${{ vars.ECR_TARGET_ALLOCATOR_STAGING_REPO }}
ECR_TARGET_ALLOCATOR_RELEASE_REPO: ${{ vars.ECR_TARGET_ALLOCATOR_RELEASE_REPO }}

on:
workflow_call:
inputs:
Expand Down Expand Up @@ -41,7 +41,7 @@ on:
description: "Run Test on the new container image"
default: true
type: boolean
region:
region:
description: "AWS Region to run the build/test on"
default: "us-west-2"
type: string
Expand All @@ -54,6 +54,7 @@ jobs:
permissions:
id-token: write
contents: read

steps:
- uses: actions/checkout@v3
with:
Expand Down Expand Up @@ -87,17 +88,43 @@ jobs:
if: steps.cached_binaries.outputs.cache-hit == false
uses: docker/setup-qemu-action@v1

- name: Build Cloudwatch Agent Operator Image and push to ECR
- name: Build Cloudwatch Agent Operator AMD64 Image
uses: docker/build-push-action@v4
if: steps.cached_binaries.outputs.cache-hit == false
with:
file: ./Dockerfile
context: .
push: true
platforms: linux/amd64
tags: |
${{ env.ECR_OPERATOR_STAGING_REPO }}:${{ inputs.tag }}-linux-amd64
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
VERSION_PKG=${{ env.VERSION_PKG }}
VERSION=${{ inputs.tag }}
VERSION_DATE=${{ env.VERSION_DATE }}
AGENT_VERSION=${{ env.AGENT_VERSION }}
AUTO_INSTRUMENTATION_JAVA_VERSION=${{ env.AUTO_INSTRUMENTATION_JAVA_VERSION }}
AUTO_INSTRUMENTATION_PYTHON_VERSION=${{ env.AUTO_INSTRUMENTATION_PYTHON_VERSION }}
AUTO_INSTRUMENTATION_DOTNET_VERSION=${{ env.AUTO_INSTRUMENTATION_DOTNET_VERSION }}
AUTO_INSTRUMENTATION_NODEJS_VERSION=${{ env.AUTO_INSTRUMENTATION_NODEJS_VERSION }}
DCMG_EXPORTER_VERSION=${{ env.DCMG_EXPORTER_VERSION }}
NEURON_MONITOR_VERSION=${{ env.NEURON_MONITOR_VERSION }}
TARGET_ALLOCATOR_VERSION=${{ env.TARGET_ALLOCATOR_VERSION }}
outputs: type=image,push=true
provenance: false

- name: Build Cloudwatch Agent Operator ARM64 Image
uses: docker/build-push-action@v4
if: steps.cached_binaries.outputs.cache-hit == false
with:
file: ./Dockerfile
context: .
push: true
platforms: linux/amd64,linux/arm64
platforms: linux/arm64
tags: |
${{ env.ECR_OPERATOR_STAGING_REPO }}:${{ inputs.tag }}
${{ env.ECR_OPERATOR_STAGING_REPO }}:${{ inputs.target-sha }}
${{ env.ECR_OPERATOR_STAGING_REPO }}:${{ inputs.tag }}-linux-arm64
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
Expand Down Expand Up @@ -157,20 +184,38 @@ jobs:
run: |
go mod download
go mod tidy
export GOARCH=arm64 && make targetallocator
export GOARCH=amd64 && make targetallocator
mkdir -p cmd/amazon-cloudwatch-agent-target-allocator/bin
Copy link
Contributor

Choose a reason for hiding this comment

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

why are we making a /bin directory here?

GOARCH=amd64 make targetallocator
GOARCH=arm64 make targetallocator
ls -la cmd/amazon-cloudwatch-agent-target-allocator/bin/

- name: Build Cloudwatch Agent Target Allocator Image and push to ECR
- name: Build Target Allocator AMD64 Image
uses: docker/build-push-action@v4
if: steps.cached_binaries.outputs.cache-hit == false
with:
file: ./cmd/amazon-cloudwatch-agent-target-allocator/Dockerfile
context: ./cmd/amazon-cloudwatch-agent-target-allocator
push: true
platforms: linux/amd64
tags: |
${{ env.ECR_TARGET_ALLOCATOR_STAGING_REPO }}:${{ inputs.tag }}
${{ env.ECR_TARGET_ALLOCATOR_STAGING_REPO }}:${{ inputs.target-sha }}
platforms: linux/amd64, linux/arm64
${{ env.ECR_TARGET_ALLOCATOR_STAGING_REPO }}:${{ inputs.tag }}-linux-amd64
cache-from: type=gha
cache-to: type=gha,mode=max
provenance: false

- name: Build Target Allocator ARM64 Image
if: steps.cached_binaries.outputs.cache-hit == false
uses: docker/build-push-action@v4
with:
file: ./cmd/amazon-cloudwatch-agent-target-allocator/Dockerfile
context: ./cmd/amazon-cloudwatch-agent-target-allocator
push: true
platforms: linux/arm64
tags: |
${{ env.ECR_TARGET_ALLOCATOR_STAGING_REPO }}:${{ inputs.tag }}-linux-arm64
cache-from: type=gha
cache-to: type=gha,mode=max
provenance: false

bypass-info:
if: ${{ inputs.e2e-test-bypass-link != '' || inputs.e2e-test-bypass-approver != '' }}
Expand All @@ -185,7 +230,7 @@ jobs:
e2e-test:
if: ${{inputs.test-image-before-upload}}
name: "Application Signals E2E Test"
needs: MakeBinary
needs: CreateManifest
uses: ./.github/workflows/application-signals-e2e-test.yml
secrets: inherit
permissions:
Expand All @@ -196,7 +241,7 @@ jobs:

push-release-ecr:
if: ${{ inputs.release }}
needs: [ MakeTABinary, e2e-test ]
needs: [ MakeTABinary, e2e-test, CreateManifest ]
permissions:
id-token: write
contents: read
Expand All @@ -213,12 +258,64 @@ jobs:
role-to-assume: ${{ env.AWS_ASSUME_ROLE }}
aws-region: ${{inputs.region}}

- name: Login ECR
- name: Login to ECR
id: login-ecr
if: steps.cached_binaries.outputs.cache-hit == false
uses: aws-actions/amazon-ecr-login@v1

- name: Push image to release ECR
run: |
docker buildx imagetools create \
-t ${{ env.ECR_OPERATOR_RELEASE_IMAGE }} \
${{ env.ECR_OPERATOR_STAGING_REPO }}:${{ inputs.tag }}
${{ env.ECR_OPERATOR_STAGING_REPO }}:${{ inputs.tag }}

CreateManifest:
needs: [ MakeBinary, MakeTABinary ]
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ inputs.target-sha }}
repository: ${{inputs.repository}}

- name: Set up Go 1.x
uses: actions/setup-go@v4
with:
go-version: '>1.22'
cache: true

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ env.AWS_ASSUME_ROLE }}
aws-region: ${{inputs.region}}

- name: Login ECR
uses: aws-actions/amazon-ecr-login@v2

Choose a reason for hiding this comment

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

Docker has a multi-tag feature thats also useful to prevent need for re-building a new image just to add the new tag. Not blocking comment

docker manifest create \
  ${{ env.ECR_TARGET_ALLOCATOR_STAGING_REPO }}:${{ inputs.tag }} \
  ${{ env.ECR_TARGET_ALLOCATOR_STAGING_REPO }}:${{ github.sha }} \
  --amend ${{ env.ECR_TARGET_ALLOCATOR_STAGING_REPO }}:${{ inputs.tag }}-linux-amd64 \
  --amend ${{ env.ECR_TARGET_ALLOCATOR_STAGING_REPO }}:${{ inputs.tag }}-linux-arm64

docker manifest push ${{ env.ECR_TARGET_ALLOCATOR_STAGING_REPO }}:${{ inputs.tag }}
docker manifest push ${{ env.ECR_TARGET_ALLOCATOR_STAGING_REPO }}:${{ github.sha }}

- name: Create manifests
run: |
docker manifest create ${{ env.ECR_TARGET_ALLOCATOR_STAGING_REPO }}:${{ inputs.tag }} \
--amend ${{ env.ECR_TARGET_ALLOCATOR_STAGING_REPO }}:${{ inputs.tag }}-linux-amd64 \
--amend ${{ env.ECR_TARGET_ALLOCATOR_STAGING_REPO }}:${{ inputs.tag }}-linux-arm64
docker manifest push ${{ env.ECR_TARGET_ALLOCATOR_STAGING_REPO }}:${{ inputs.tag }}

docker manifest create ${{ env.ECR_TARGET_ALLOCATOR_STAGING_REPO }}:${{ github.sha }} \
--amend ${{ env.ECR_TARGET_ALLOCATOR_STAGING_REPO }}:${{ inputs.tag }}-linux-amd64 \
--amend ${{ env.ECR_TARGET_ALLOCATOR_STAGING_REPO }}:${{ inputs.tag }}-linux-arm64
docker manifest push ${{ env.ECR_TARGET_ALLOCATOR_STAGING_REPO }}:${{ github.sha }}


docker manifest create ${{ env.ECR_OPERATOR_STAGING_REPO }}:${{ inputs.tag }} \
--amend ${{ env.ECR_OPERATOR_STAGING_REPO }}:${{ inputs.tag }}-linux-amd64 \
--amend ${{ env.ECR_OPERATOR_STAGING_REPO }}:${{ inputs.tag }}-linux-arm64
docker manifest push ${{ env.ECR_OPERATOR_STAGING_REPO }}:${{ inputs.tag }}

docker manifest create ${{ env.ECR_OPERATOR_STAGING_REPO }}:${{ github.sha }} \
--amend ${{ env.ECR_OPERATOR_STAGING_REPO }}:${{ inputs.tag }}-linux-amd64 \
--amend ${{ env.ECR_OPERATOR_STAGING_REPO }}:${{ inputs.tag }}-linux-arm64
docker manifest push ${{ env.ECR_OPERATOR_STAGING_REPO }}:${{ github.sha }}
Loading