Skip to content

Commit 388bdc5

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

File tree

1 file changed

+111
-17
lines changed

1 file changed

+111
-17
lines changed

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

Lines changed: 111 additions & 17 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,36 @@ 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
192+
uses: docker/build-push-action@v4
193+
with:
194+
file: ./cmd/amazon-cloudwatch-agent-target-allocator/Dockerfile
195+
context: ./cmd/amazon-cloudwatch-agent-target-allocator
196+
push: true
197+
platforms: linux/amd64
198+
tags: |
199+
${{ env.ECR_TARGET_ALLOCATOR_STAGING_REPO }}:${{ inputs.tag }}-linux-amd64
200+
cache-from: type=gha
201+
cache-to: type=gha,mode=max
202+
provenance: false
203+
204+
- name: Build Target Allocator ARM64 Image
164205
uses: docker/build-push-action@v4
165-
if: steps.cached_binaries.outputs.cache-hit == false
166206
with:
167207
file: ./cmd/amazon-cloudwatch-agent-target-allocator/Dockerfile
168208
context: ./cmd/amazon-cloudwatch-agent-target-allocator
169209
push: true
210+
platforms: linux/arm64
170211
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
212+
${{ env.ECR_TARGET_ALLOCATOR_STAGING_REPO }}:${{ inputs.tag }}-linux-arm64
213+
cache-from: type=gha
214+
cache-to: type=gha,mode=max
215+
provenance: false
174216

175217
bypass-info:
176218
if: ${{ inputs.e2e-test-bypass-link != '' || inputs.e2e-test-bypass-approver != '' }}
@@ -185,7 +227,7 @@ jobs:
185227
e2e-test:
186228
if: ${{inputs.test-image-before-upload}}
187229
name: "Application Signals E2E Test"
188-
needs: MakeBinary
230+
needs: CreateManifest
189231
uses: ./.github/workflows/application-signals-e2e-test.yml
190232
secrets: inherit
191233
permissions:
@@ -196,7 +238,7 @@ jobs:
196238

197239
push-release-ecr:
198240
if: ${{ inputs.release }}
199-
needs: [ MakeTABinary, e2e-test ]
241+
needs: [ MakeTABinary, e2e-test, CreateManifest ]
200242
permissions:
201243
id-token: write
202244
contents: read
@@ -213,12 +255,64 @@ jobs:
213255
role-to-assume: ${{ env.AWS_ASSUME_ROLE }}
214256
aws-region: ${{inputs.region}}
215257

216-
- name: Login ECR
258+
- name: Login to ECR
217259
id: login-ecr
260+
if: steps.cached_binaries.outputs.cache-hit == false
218261
uses: aws-actions/amazon-ecr-login@v1
219262

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

0 commit comments

Comments
 (0)