Skip to content

Commit b5d464b

Browse files
committed
Splitting arm/amd tags for operator and target allocator
1 parent 9ba9076 commit b5d464b

File tree

1 file changed

+112
-16
lines changed

1 file changed

+112
-16
lines changed

.github/workflows/build-and-upload.yml

Lines changed: 112 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ env:
99
ECR_OPERATOR_RELEASE_IMAGE: ${{ vars.ECR_OPERATOR_RELEASE_IMAGE }}
1010
ECR_TARGET_ALLOCATOR_STAGING_REPO: ${{ vars.ECR_TARGET_ALLOCATOR_STAGING_REPO }}
1111
ECR_TARGET_ALLOCATOR_RELEASE_REPO: ${{ vars.ECR_TARGET_ALLOCATOR_RELEASE_REPO }}
12-
12+
1313
on:
1414
workflow_call:
1515
inputs:
@@ -41,7 +41,7 @@ on:
4141
description: "Run Test on the new container image"
4242
default: true
4343
type: boolean
44-
region:
44+
region:
4545
description: "AWS Region to run the build/test on"
4646
default: "us-west-2"
4747
type: string
@@ -87,17 +87,43 @@ jobs:
8787
if: steps.cached_binaries.outputs.cache-hit == false
8888
uses: docker/setup-qemu-action@v1
8989

90-
- name: Build Cloudwatch Agent Operator Image and push to ECR
90+
- name: Build Cloudwatch Agent Operator AMD64 Image
9191
uses: docker/build-push-action@v4
9292
if: steps.cached_binaries.outputs.cache-hit == false
9393
with:
9494
file: ./Dockerfile
9595
context: .
9696
push: true
97-
platforms: linux/amd64,linux/arm64
97+
platforms: linux/amd64
9898
tags: |
99-
${{ env.ECR_OPERATOR_STAGING_REPO }}:${{ inputs.tag }}
100-
${{ env.ECR_OPERATOR_STAGING_REPO }}:${{ inputs.target-sha }}
99+
${{ env.ECR_OPERATOR_STAGING_REPO }}:${{ inputs.tag }}-linux-amd64
100+
cache-from: type=gha
101+
cache-to: type=gha,mode=max
102+
build-args: |
103+
VERSION_PKG=${{ env.VERSION_PKG }}
104+
VERSION=${{ inputs.tag }}
105+
VERSION_DATE=${{ env.VERSION_DATE }}
106+
AGENT_VERSION=${{ env.AGENT_VERSION }}
107+
AUTO_INSTRUMENTATION_JAVA_VERSION=${{ env.AUTO_INSTRUMENTATION_JAVA_VERSION }}
108+
AUTO_INSTRUMENTATION_PYTHON_VERSION=${{ env.AUTO_INSTRUMENTATION_PYTHON_VERSION }}
109+
AUTO_INSTRUMENTATION_DOTNET_VERSION=${{ env.AUTO_INSTRUMENTATION_DOTNET_VERSION }}
110+
AUTO_INSTRUMENTATION_NODEJS_VERSION=${{ env.AUTO_INSTRUMENTATION_NODEJS_VERSION }}
111+
DCMG_EXPORTER_VERSION=${{ env.DCMG_EXPORTER_VERSION }}
112+
NEURON_MONITOR_VERSION=${{ env.NEURON_MONITOR_VERSION }}
113+
TARGET_ALLOCATOR_VERSION=${{ env.TARGET_ALLOCATOR_VERSION }}
114+
outputs: type=image,push=true
115+
provenance: false
116+
117+
- name: Build Cloudwatch Agent Operator ARM64 Image
118+
uses: docker/build-push-action@v4
119+
if: steps.cached_binaries.outputs.cache-hit == false
120+
with:
121+
file: ./Dockerfile
122+
context: .
123+
push: true
124+
platforms: linux/arm64
125+
tags: |
126+
${{ env.ECR_OPERATOR_STAGING_REPO }}:${{ inputs.tag }}-linux-arm64
101127
cache-from: type=gha
102128
cache-to: type=gha,mode=max
103129
build-args: |
@@ -157,20 +183,38 @@ jobs:
157183
run: |
158184
go mod download
159185
go mod tidy
160-
export GOARCH=arm64 && make targetallocator
161-
export GOARCH=amd64 && make targetallocator
186+
mkdir -p cmd/amazon-cloudwatch-agent-target-allocator/bin
187+
GOARCH=amd64 make targetallocator
188+
GOARCH=arm64 make targetallocator
189+
ls -la cmd/amazon-cloudwatch-agent-target-allocator/bin/
162190
163-
- name: Build Cloudwatch Agent Target Allocator Image and push to ECR
191+
- name: Build Target Allocator AMD64 Image
164192
uses: docker/build-push-action@v4
165193
if: steps.cached_binaries.outputs.cache-hit == false
166194
with:
167195
file: ./cmd/amazon-cloudwatch-agent-target-allocator/Dockerfile
168196
context: ./cmd/amazon-cloudwatch-agent-target-allocator
169197
push: true
198+
platforms: linux/amd64
199+
tags: |
200+
${{ env.ECR_TARGET_ALLOCATOR_STAGING_REPO }}:${{ inputs.tag }}-linux-amd64
201+
cache-from: type=gha
202+
cache-to: type=gha,mode=max
203+
provenance: false
204+
205+
- name: Build Target Allocator ARM64 Image
206+
if: steps.cached_binaries.outputs.cache-hit == false
207+
uses: docker/build-push-action@v4
208+
with:
209+
file: ./cmd/amazon-cloudwatch-agent-target-allocator/Dockerfile
210+
context: ./cmd/amazon-cloudwatch-agent-target-allocator
211+
push: true
212+
platforms: linux/arm64
170213
tags: |
171-
${{ env.ECR_TARGET_ALLOCATOR_STAGING_REPO }}:${{ inputs.tag }}
172-
${{ env.ECR_TARGET_ALLOCATOR_STAGING_REPO }}:${{ inputs.target-sha }}
173-
platforms: linux/amd64, linux/arm64
214+
${{ env.ECR_TARGET_ALLOCATOR_STAGING_REPO }}:${{ inputs.tag }}-linux-arm64
215+
cache-from: type=gha
216+
cache-to: type=gha,mode=max
217+
provenance: false
174218

175219
bypass-info:
176220
if: ${{ inputs.e2e-test-bypass-link != '' || inputs.e2e-test-bypass-approver != '' }}
@@ -185,7 +229,7 @@ jobs:
185229
e2e-test:
186230
if: ${{inputs.test-image-before-upload}}
187231
name: "Application Signals E2E Test"
188-
needs: MakeBinary
232+
needs: CreateManifest
189233
uses: ./.github/workflows/application-signals-e2e-test.yml
190234
secrets: inherit
191235
permissions:
@@ -196,7 +240,7 @@ jobs:
196240

197241
push-release-ecr:
198242
if: ${{ inputs.release }}
199-
needs: [ MakeTABinary, e2e-test ]
243+
needs: [ MakeTABinary, e2e-test, CreateManifest ]
200244
permissions:
201245
id-token: write
202246
contents: read
@@ -213,12 +257,64 @@ jobs:
213257
role-to-assume: ${{ env.AWS_ASSUME_ROLE }}
214258
aws-region: ${{inputs.region}}
215259

216-
- name: Login ECR
260+
- name: Login to ECR
217261
id: login-ecr
262+
if: steps.cached_binaries.outputs.cache-hit == false
218263
uses: aws-actions/amazon-ecr-login@v1
219264

220265
- name: Push image to release ECR
221266
run: |
222267
docker buildx imagetools create \
223268
-t ${{ env.ECR_OPERATOR_RELEASE_IMAGE }} \
224-
${{ env.ECR_OPERATOR_STAGING_REPO }}:${{ inputs.tag }}
269+
${{ env.ECR_OPERATOR_STAGING_REPO }}:${{ inputs.tag }}
270+
271+
CreateManifest:
272+
needs: [ MakeBinary, MakeTABinary ]
273+
runs-on: ubuntu-latest
274+
permissions:
275+
id-token: write
276+
contents: read
277+
steps:
278+
- uses: actions/checkout@v3
279+
with:
280+
fetch-depth: 0
281+
ref: ${{ inputs.target-sha }}
282+
repository: ${{inputs.repository}}
283+
284+
- name: Set up Go 1.x
285+
uses: actions/setup-go@v4
286+
with:
287+
go-version: '>1.22'
288+
cache: true
289+
290+
- name: Configure AWS Credentials
291+
uses: aws-actions/configure-aws-credentials@v4
292+
with:
293+
role-to-assume: ${{ env.AWS_ASSUME_ROLE }}
294+
aws-region: ${{inputs.region}}
295+
296+
- name: Login ECR
297+
uses: aws-actions/amazon-ecr-login@v2
298+
299+
- name: Create manifests
300+
run: |
301+
docker manifest create ${{ env.ECR_TARGET_ALLOCATOR_STAGING_REPO }}:${{ inputs.tag }} \
302+
--amend ${{ env.ECR_TARGET_ALLOCATOR_STAGING_REPO }}:${{ inputs.tag }}-linux-amd64 \
303+
--amend ${{ env.ECR_TARGET_ALLOCATOR_STAGING_REPO }}:${{ inputs.tag }}-linux-arm64
304+
docker manifest push ${{ env.ECR_TARGET_ALLOCATOR_STAGING_REPO }}:${{ inputs.tag }}
305+
306+
docker manifest create ${{ env.ECR_TARGET_ALLOCATOR_STAGING_REPO }}:${{ github.sha }} \
307+
--amend ${{ env.ECR_TARGET_ALLOCATOR_STAGING_REPO }}:${{ inputs.tag }}-linux-amd64 \
308+
--amend ${{ env.ECR_TARGET_ALLOCATOR_STAGING_REPO }}:${{ inputs.tag }}-linux-arm64
309+
docker manifest push ${{ env.ECR_TARGET_ALLOCATOR_STAGING_REPO }}:${{ github.sha }}
310+
311+
312+
docker manifest create ${{ env.ECR_OPERATOR_STAGING_REPO }}:${{ inputs.tag }} \
313+
--amend ${{ env.ECR_OPERATOR_STAGING_REPO }}:${{ inputs.tag }}-linux-amd64 \
314+
--amend ${{ env.ECR_OPERATOR_STAGING_REPO }}:${{ inputs.tag }}-linux-arm64
315+
docker manifest push ${{ env.ECR_OPERATOR_STAGING_REPO }}:${{ inputs.tag }}
316+
317+
docker manifest create ${{ env.ECR_OPERATOR_STAGING_REPO }}:${{ github.sha }} \
318+
--amend ${{ env.ECR_OPERATOR_STAGING_REPO }}:${{ inputs.tag }}-linux-amd64 \
319+
--amend ${{ env.ECR_OPERATOR_STAGING_REPO }}:${{ inputs.tag }}-linux-arm64
320+
docker manifest push ${{ env.ECR_OPERATOR_STAGING_REPO }}:${{ github.sha }}

0 commit comments

Comments
 (0)