Skip to content

Commit 9687c7b

Browse files
authored
Splitting arm/amd tags for operator and target allocator (#304)
1 parent 9ba9076 commit 9687c7b

File tree

1 file changed

+113
-16
lines changed

1 file changed

+113
-16
lines changed

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

Lines changed: 113 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
@@ -54,6 +54,7 @@ jobs:
5454
permissions:
5555
id-token: write
5656
contents: read
57+
5758
steps:
5859
- uses: actions/checkout@v3
5960
with:
@@ -87,17 +88,43 @@ jobs:
8788
if: steps.cached_binaries.outputs.cache-hit == false
8889
uses: docker/setup-qemu-action@v1
8990

90-
- name: Build Cloudwatch Agent Operator Image and push to ECR
91+
- name: Build Cloudwatch Agent Operator AMD64 Image
92+
uses: docker/build-push-action@v4
93+
if: steps.cached_binaries.outputs.cache-hit == false
94+
with:
95+
file: ./Dockerfile
96+
context: .
97+
push: true
98+
platforms: linux/amd64
99+
tags: |
100+
${{ env.ECR_OPERATOR_STAGING_REPO }}:${{ inputs.tag }}-linux-amd64
101+
cache-from: type=gha
102+
cache-to: type=gha,mode=max
103+
build-args: |
104+
VERSION_PKG=${{ env.VERSION_PKG }}
105+
VERSION=${{ inputs.tag }}
106+
VERSION_DATE=${{ env.VERSION_DATE }}
107+
AGENT_VERSION=${{ env.AGENT_VERSION }}
108+
AUTO_INSTRUMENTATION_JAVA_VERSION=${{ env.AUTO_INSTRUMENTATION_JAVA_VERSION }}
109+
AUTO_INSTRUMENTATION_PYTHON_VERSION=${{ env.AUTO_INSTRUMENTATION_PYTHON_VERSION }}
110+
AUTO_INSTRUMENTATION_DOTNET_VERSION=${{ env.AUTO_INSTRUMENTATION_DOTNET_VERSION }}
111+
AUTO_INSTRUMENTATION_NODEJS_VERSION=${{ env.AUTO_INSTRUMENTATION_NODEJS_VERSION }}
112+
DCMG_EXPORTER_VERSION=${{ env.DCMG_EXPORTER_VERSION }}
113+
NEURON_MONITOR_VERSION=${{ env.NEURON_MONITOR_VERSION }}
114+
TARGET_ALLOCATOR_VERSION=${{ env.TARGET_ALLOCATOR_VERSION }}
115+
outputs: type=image,push=true
116+
provenance: false
117+
118+
- name: Build Cloudwatch Agent Operator ARM64 Image
91119
uses: docker/build-push-action@v4
92120
if: steps.cached_binaries.outputs.cache-hit == false
93121
with:
94122
file: ./Dockerfile
95123
context: .
96124
push: true
97-
platforms: linux/amd64,linux/arm64
125+
platforms: linux/arm64
98126
tags: |
99-
${{ env.ECR_OPERATOR_STAGING_REPO }}:${{ inputs.tag }}
100-
${{ env.ECR_OPERATOR_STAGING_REPO }}:${{ inputs.target-sha }}
127+
${{ env.ECR_OPERATOR_STAGING_REPO }}:${{ inputs.tag }}-linux-arm64
101128
cache-from: type=gha
102129
cache-to: type=gha,mode=max
103130
build-args: |
@@ -157,20 +184,38 @@ jobs:
157184
run: |
158185
go mod download
159186
go mod tidy
160-
export GOARCH=arm64 && make targetallocator
161-
export GOARCH=amd64 && make targetallocator
187+
mkdir -p cmd/amazon-cloudwatch-agent-target-allocator/bin
188+
GOARCH=amd64 make targetallocator
189+
GOARCH=arm64 make targetallocator
190+
ls -la cmd/amazon-cloudwatch-agent-target-allocator/bin/
162191
163-
- name: Build Cloudwatch Agent Target Allocator Image and push to ECR
192+
- name: Build Target Allocator AMD64 Image
164193
uses: docker/build-push-action@v4
165194
if: steps.cached_binaries.outputs.cache-hit == false
166195
with:
167196
file: ./cmd/amazon-cloudwatch-agent-target-allocator/Dockerfile
168197
context: ./cmd/amazon-cloudwatch-agent-target-allocator
169198
push: true
199+
platforms: linux/amd64
170200
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
201+
${{ env.ECR_TARGET_ALLOCATOR_STAGING_REPO }}:${{ inputs.tag }}-linux-amd64
202+
cache-from: type=gha
203+
cache-to: type=gha,mode=max
204+
provenance: false
205+
206+
- name: Build Target Allocator ARM64 Image
207+
if: steps.cached_binaries.outputs.cache-hit == false
208+
uses: docker/build-push-action@v4
209+
with:
210+
file: ./cmd/amazon-cloudwatch-agent-target-allocator/Dockerfile
211+
context: ./cmd/amazon-cloudwatch-agent-target-allocator
212+
push: true
213+
platforms: linux/arm64
214+
tags: |
215+
${{ env.ECR_TARGET_ALLOCATOR_STAGING_REPO }}:${{ inputs.tag }}-linux-arm64
216+
cache-from: type=gha
217+
cache-to: type=gha,mode=max
218+
provenance: false
174219

175220
bypass-info:
176221
if: ${{ inputs.e2e-test-bypass-link != '' || inputs.e2e-test-bypass-approver != '' }}
@@ -185,7 +230,7 @@ jobs:
185230
e2e-test:
186231
if: ${{inputs.test-image-before-upload}}
187232
name: "Application Signals E2E Test"
188-
needs: MakeBinary
233+
needs: CreateManifest
189234
uses: ./.github/workflows/application-signals-e2e-test.yml
190235
secrets: inherit
191236
permissions:
@@ -196,7 +241,7 @@ jobs:
196241

197242
push-release-ecr:
198243
if: ${{ inputs.release }}
199-
needs: [ MakeTABinary, e2e-test ]
244+
needs: [ MakeTABinary, e2e-test, CreateManifest ]
200245
permissions:
201246
id-token: write
202247
contents: read
@@ -213,12 +258,64 @@ jobs:
213258
role-to-assume: ${{ env.AWS_ASSUME_ROLE }}
214259
aws-region: ${{inputs.region}}
215260

216-
- name: Login ECR
261+
- name: Login to ECR
217262
id: login-ecr
263+
if: steps.cached_binaries.outputs.cache-hit == false
218264
uses: aws-actions/amazon-ecr-login@v1
219265

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

0 commit comments

Comments
 (0)