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+
1313on :
1414 workflow_call :
1515 inputs :
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
4848
4949
5050jobs :
51+ GetBuildArgs :
52+ uses : ./.github/workflows/operator-build-args.yml
5153 MakeBinary :
54+ needs : GetBuildArgs
5255 name : ' MakeContainerImage'
5356 runs-on : ubuntu-latest
5457 permissions :
5558 id-token : write
5659 contents : read
60+
5761 steps :
5862 - uses : actions/checkout@v3
5963 with :
@@ -87,31 +91,35 @@ jobs:
8791 if : steps.cached_binaries.outputs.cache-hit == false
8892 uses : docker/setup-qemu-action@v1
8993
90- - name : Build Cloudwatch Agent Operator Image and push to ECR
94+ - name : Build Cloudwatch Agent Operator AMD64 Image
9195 uses : docker/build-push-action@v4
9296 if : steps.cached_binaries.outputs.cache-hit == false
9397 with :
9498 file : ./Dockerfile
9599 context : .
96100 push : true
97- platforms : linux/amd64,linux/arm64
101+ platforms : linux/amd64
98102 tags : |
99- ${{ env.ECR_OPERATOR_STAGING_REPO }}:${{ inputs.tag }}
100- ${{ env.ECR_OPERATOR_STAGING_REPO }}:${{ inputs.target-sha }}
103+ ${{ env.ECR_OPERATOR_STAGING_REPO }}:${{ inputs.tag }}-linux-amd64
101104 cache-from : type=gha
102105 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 }}
106+ build-args : ${{ needs.GetBuildArgs.outputs.build_args }}
107+ outputs : type=image,push=true
108+ provenance : false
109+
110+ - name : Build Cloudwatch Agent Operator ARM64 Image
111+ uses : docker/build-push-action@v4
112+ if : steps.cached_binaries.outputs.cache-hit == false
113+ with :
114+ file : ./Dockerfile
115+ context : .
116+ push : true
117+ platforms : linux/arm64
118+ tags : |
119+ ${{ env.ECR_OPERATOR_STAGING_REPO }}:${{ inputs.tag }}-linux-arm64
120+ cache-from : type=gha
121+ cache-to : type=gha,mode=max
122+ build-args : ${{ needs.GetBuildArgs.outputs.build_args }}
115123 outputs : type=image,push=true
116124 provenance : false
117125
@@ -157,20 +165,38 @@ jobs:
157165 run : |
158166 go mod download
159167 go mod tidy
160- export GOARCH=arm64 && make targetallocator
161- export GOARCH=amd64 && make targetallocator
168+ mkdir -p cmd/amazon-cloudwatch-agent-target-allocator/bin
169+ GOARCH=amd64 make targetallocator
170+ GOARCH=arm64 make targetallocator
171+ ls -la cmd/amazon-cloudwatch-agent-target-allocator/bin/
162172
163- - name : Build Cloudwatch Agent Target Allocator Image and push to ECR
173+ - name : Build Target Allocator AMD64 Image
164174 uses : docker/build-push-action@v4
165175 if : steps.cached_binaries.outputs.cache-hit == false
166176 with :
167177 file : ./cmd/amazon-cloudwatch-agent-target-allocator/Dockerfile
168178 context : ./cmd/amazon-cloudwatch-agent-target-allocator
169179 push : true
180+ platforms : linux/amd64
181+ tags : |
182+ ${{ env.ECR_TARGET_ALLOCATOR_STAGING_REPO }}:${{ inputs.tag }}-linux-amd64
183+ cache-from : type=gha
184+ cache-to : type=gha,mode=max
185+ provenance : false
186+
187+ - name : Build Target Allocator ARM64 Image
188+ if : steps.cached_binaries.outputs.cache-hit == false
189+ uses : docker/build-push-action@v4
190+ with :
191+ file : ./cmd/amazon-cloudwatch-agent-target-allocator/Dockerfile
192+ context : ./cmd/amazon-cloudwatch-agent-target-allocator
193+ push : true
194+ platforms : linux/arm64
170195 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
196+ ${{ env.ECR_TARGET_ALLOCATOR_STAGING_REPO }}:${{ inputs.tag }}-linux-arm64
197+ cache-from : type=gha
198+ cache-to : type=gha,mode=max
199+ provenance : false
174200
175201 bypass-info :
176202 if : ${{ inputs.e2e-test-bypass-link != '' || inputs.e2e-test-bypass-approver != '' }}
@@ -185,7 +211,7 @@ jobs:
185211 e2e-test :
186212 if : ${{inputs.test-image-before-upload}}
187213 name : " Application Signals E2E Test"
188- needs : MakeBinary
214+ needs : CreateManifest
189215 uses : ./.github/workflows/application-signals-e2e-test.yml
190216 secrets : inherit
191217 permissions :
@@ -196,7 +222,7 @@ jobs:
196222
197223 push-release-ecr :
198224 if : ${{ inputs.release }}
199- needs : [ MakeTABinary, e2e-test ]
225+ needs : [ MakeTABinary, e2e-test, CreateManifest ]
200226 permissions :
201227 id-token : write
202228 contents : read
@@ -213,12 +239,64 @@ jobs:
213239 role-to-assume : ${{ env.AWS_ASSUME_ROLE }}
214240 aws-region : ${{inputs.region}}
215241
216- - name : Login ECR
242+ - name : Login to ECR
217243 id : login-ecr
244+ if : steps.cached_binaries.outputs.cache-hit == false
218245 uses : aws-actions/amazon-ecr-login@v1
219246
220247 - name : Push image to release ECR
221248 run : |
222249 docker buildx imagetools create \
223250 -t ${{ env.ECR_OPERATOR_RELEASE_IMAGE }} \
224- ${{ env.ECR_OPERATOR_STAGING_REPO }}:${{ inputs.tag }}
251+ ${{ env.ECR_OPERATOR_STAGING_REPO }}:${{ inputs.tag }}
252+
253+ CreateManifest :
254+ needs : [ MakeBinary, MakeTABinary ]
255+ runs-on : ubuntu-latest
256+ permissions :
257+ id-token : write
258+ contents : read
259+ steps :
260+ - uses : actions/checkout@v3
261+ with :
262+ fetch-depth : 0
263+ ref : ${{ inputs.target-sha }}
264+ repository : ${{inputs.repository}}
265+
266+ - name : Set up Go 1.x
267+ uses : actions/setup-go@v4
268+ with :
269+ go-version : ' >1.22'
270+ cache : true
271+
272+ - name : Configure AWS Credentials
273+ uses : aws-actions/configure-aws-credentials@v4
274+ with :
275+ role-to-assume : ${{ env.AWS_ASSUME_ROLE }}
276+ aws-region : ${{inputs.region}}
277+
278+ - name : Login ECR
279+ uses : aws-actions/amazon-ecr-login@v2
280+
281+ - name : Create manifests
282+ run : |
283+ docker manifest create ${{ env.ECR_TARGET_ALLOCATOR_STAGING_REPO }}:${{ inputs.tag }} \
284+ --amend ${{ env.ECR_TARGET_ALLOCATOR_STAGING_REPO }}:${{ inputs.tag }}-linux-amd64 \
285+ --amend ${{ env.ECR_TARGET_ALLOCATOR_STAGING_REPO }}:${{ inputs.tag }}-linux-arm64
286+ docker manifest push ${{ env.ECR_TARGET_ALLOCATOR_STAGING_REPO }}:${{ inputs.tag }}
287+
288+ docker manifest create ${{ env.ECR_TARGET_ALLOCATOR_STAGING_REPO }}:${{ github.sha }} \
289+ --amend ${{ env.ECR_TARGET_ALLOCATOR_STAGING_REPO }}:${{ inputs.tag }}-linux-amd64 \
290+ --amend ${{ env.ECR_TARGET_ALLOCATOR_STAGING_REPO }}:${{ inputs.tag }}-linux-arm64
291+ docker manifest push ${{ env.ECR_TARGET_ALLOCATOR_STAGING_REPO }}:${{ github.sha }}
292+
293+
294+ docker manifest create ${{ env.ECR_OPERATOR_STAGING_REPO }}:${{ inputs.tag }} \
295+ --amend ${{ env.ECR_OPERATOR_STAGING_REPO }}:${{ inputs.tag }}-linux-amd64 \
296+ --amend ${{ env.ECR_OPERATOR_STAGING_REPO }}:${{ inputs.tag }}-linux-arm64
297+ docker manifest push ${{ env.ECR_OPERATOR_STAGING_REPO }}:${{ inputs.tag }}
298+
299+ docker manifest create ${{ env.ECR_OPERATOR_STAGING_REPO }}:${{ github.sha }} \
300+ --amend ${{ env.ECR_OPERATOR_STAGING_REPO }}:${{ inputs.tag }}-linux-amd64 \
301+ --amend ${{ env.ECR_OPERATOR_STAGING_REPO }}:${{ inputs.tag }}-linux-arm64
302+ docker manifest push ${{ env.ECR_OPERATOR_STAGING_REPO }}:${{ github.sha }}
0 commit comments