@@ -73,8 +73,11 @@ gamma_account_id="626332813196"
7373
7474DOCKER_HUB_SECRET=" com.amazonaws.dockerhub.aws-for-fluent-bit.credentials"
7575
76+ ARCHITECTURES=(" amd64" " arm64" )
77+
7678publish_to_docker_hub () {
7779 DRY_RUN=" ${DRY_RUN:- true} "
80+ export DOCKER_CLI_EXPERIMENTAL=enabled
7881
7982 username=" $( aws secretsmanager get-secret-value --secret-id $DOCKER_HUB_SECRET --region us-west-2 | jq -r ' .SecretString | fromjson.username' ) "
8083 password=" $( aws secretsmanager get-secret-value --secret-id $DOCKER_HUB_SECRET --region us-west-2 | jq -r ' .SecretString | fromjson.password' ) "
@@ -90,13 +93,23 @@ publish_to_docker_hub() {
9093
9194 # Publish to DockerHub only if $DRY_RUN is set to false
9295 if [[ " ${DRY_RUN} " == " false" ]]; then
93- docker tag ${1} ${2}
94- docker push ${1}
95- docker push ${2}
96+ for arch in " ${ARCHITECTURES[@]} "
97+ do
98+ docker tag ${1} :" $arch " ${1} :" ${arch} " -${AWS_FOR_FLUENT_BIT_VERSION}
99+ docker push ${1} :" $arch " -${AWS_FOR_FLUENT_BIT_VERSION}
100+ done
101+
102+ create_manifest_list ${1} " latest"
103+ create_manifest_list ${1} ${AWS_FOR_FLUENT_BIT_VERSION}
104+
96105 else
97- echo " DRY_RUN: docker tag ${1} ${2} "
98- echo " DRY_RUN: docker push ${1} "
99- echo " DRY_RUN: docker push ${2} "
106+ for arch in " ${ARCHITECTURES[@]} "
107+ do
108+ echo " DRY_RUN: docker tag ${1} :${arch} ${1} :${arch} -${AWS_FOR_FLUENT_BIT_VERSION} "
109+ echo " DRY_RUN: docker push ${1} :${arch} -${AWS_FOR_FLUENT_BIT_VERSION} "
110+ done
111+ echo " DRY_RUN: create manifest list ${1} :latest"
112+ echo " DRY_RUN: create manifest list ${1} :${AWS_FOR_FLUENT_BIT_VERSION} "
100113 echo " DRY_RUN is NOT set to 'false', skipping DockerHub update. Exiting..."
101114 fi
102115
@@ -173,11 +186,41 @@ verify_ssm() {
173186 fi
174187}
175188
176- push_to_ecr () {
177- docker tag ${1} ${2}
178- ecs-cli push ${2} --region ${3} --registry-id ${4}
189+ create_manifest_list () {
190+
191+ export DOCKER_CLI_EXPERIMENTAL=enabled
192+ tag=${2}
193+
194+ # TODO: Add a way to automatically generate arch images in manifest
195+ docker manifest create ${1} :${tag} \
196+ ${1} :arm64-${AWS_FOR_FLUENT_BIT_VERSION} \
197+ ${1} :amd64-${AWS_FOR_FLUENT_BIT_VERSION}
198+
199+ for arch in " ${ARCHITECTURES[@]} "
200+ do
201+ docker manifest annotate --arch " $arch " \
202+ ${1} :${tag} \
203+ ${1} :" $arch " -${AWS_FOR_FLUENT_BIT_VERSION}
204+ done
205+
206+ # sanity check on the debug log.
207+ docker manifest inspect ${1} :${tag}
208+ docker manifest push ${1} :${tag}
209+ }
210+
211+ push_image_ecr () {
212+ account_id=${1}
213+ region=${2}
214+
215+ for arch in " ${ARCHITECTURES[@]} "
216+ do
217+ docker tag ${AWS_ACCOUNT} .dkr.ecr.${AWS_REGION} .amazonaws.com/amazon/aws-for-fluent-bit-test:" $arch " \
218+ ${account_id} .dkr.ecr.${region} .amazonaws.com/aws-for-fluent-bit:" $arch " -${AWS_FOR_FLUENT_BIT_VERSION}
219+ docker push ${account_id} .dkr.ecr.${region} .amazonaws.com/aws-for-fluent-bit:" $arch " -${AWS_FOR_FLUENT_BIT_VERSION}
220+ done
179221}
180222
223+ # TODO: remove dependency on ecs-cli
181224pull_ecr () {
182225 ecs-cli pull ${1} --region ${2}
183226}
@@ -189,8 +232,17 @@ make_repo_public() {
189232publish_ecr () {
190233 region=${1}
191234 account_id=${2}
192- push_to_ecr amazon/aws-for-fluent-bit:latest aws-for-fluent-bit:latest ${region} ${account_id}
193- push_to_ecr amazon/aws-for-fluent-bit:latest " aws-for-fluent-bit:${AWS_FOR_FLUENT_BIT_VERSION} " ${region} ${account_id}
235+ echo $region
236+ echo $account_id
237+
238+ aws ecr get-login-password --region ${region} | docker login --username AWS --password-stdin ${account_id} .dkr.ecr.${region} .amazonaws.com
239+ aws ecr create-repository --repository-name aws-for-fluent-bit --image-scanning-configuration scanOnPush=true --region ${region} || true
240+
241+ push_image_ecr ${account_id} ${region}
242+
243+ create_manifest_list ${account_id} .dkr.ecr.${region} .amazonaws.com/aws-for-fluent-bit ${AWS_FOR_FLUENT_BIT_VERSION}
244+ create_manifest_list ${account_id} .dkr.ecr.${region} .amazonaws.com/aws-for-fluent-bit " latest"
245+
194246 make_repo_public ${region}
195247}
196248
@@ -204,14 +256,15 @@ verify_ecr() {
204256 endpoint=${endpoint} .cn
205257 fi
206258
207- pull_ecr ${account_id} .dkr.ecr.${region} .${endpoint} /aws-for-fluent-bit:latest ${region}
259+ aws ecr get-login-password --region ${region} | docker login --username AWS --password-stdin ${account_id} .dkr.ecr.${region} .amazonaws.com
260+ docker pull ${account_id} .dkr.ecr.${region} .${endpoint} /aws-for-fluent-bit:latest
208261 sha1=$( docker inspect --format=' {{index .RepoDigests 0}}' ${account_id} .dkr.ecr.${region} .${endpoint} /aws-for-fluent-bit:latest)
209262
210263 if [ " ${is_sync_task} " = " true" ]; then
211264 pull_ecr ${account_id} .dkr.ecr.${region} .${endpoint} /aws-for-fluent-bit:${AWS_FOR_FLUENT_BIT_VERSION_DOCKERHUB} ${region}
212265 sha2=$( docker inspect --format=' {{index .RepoDigests 0}}' ${account_id} .dkr.ecr.${region} .${endpoint} /aws-for-fluent-bit:${AWS_FOR_FLUENT_BIT_VERSION_DOCKERHUB} )
213266 else
214- pull_ecr ${account_id} .dkr.ecr.${region} .${endpoint} /aws-for-fluent-bit:${AWS_FOR_FLUENT_BIT_VERSION} ${region }
267+ docker pull ${account_id} .dkr.ecr.${region} .${endpoint} /aws-for-fluent-bit:${AWS_FOR_FLUENT_BIT_VERSION}
215268 sha2=$( docker inspect --format=' {{index .RepoDigests 0}}' ${account_id} .dkr.ecr.${region} .${endpoint} /aws-for-fluent-bit:${AWS_FOR_FLUENT_BIT_VERSION} )
216269 fi
217270
@@ -259,7 +312,7 @@ match_two_sha() {
259312
260313if [ " ${1} " = " publish" ]; then
261314 if [ " ${2} " = " dockerhub" ]; then
262- publish_to_docker_hub amazon/aws-for-fluent-bit:latest amazon/aws-for-fluent-bit: ${AWS_FOR_FLUENT_BIT_VERSION}
315+ publish_to_docker_hub amazon/aws-for-fluent-bit
263316 fi
264317
265318 if [ " ${2} " = " aws" ]; then
417470# Following scripts will be called only from the CI/CD pipeline
418471if [ " ${1} " = " cicd-publish" ]; then
419472 if [ " ${2} " = " dockerhub" ]; then
420- publish_to_docker_hub amazon/aws-for-fluent-bit:latest amazon/aws-for-fluent-bit: ${AWS_FOR_FLUENT_BIT_VERSION}
473+ publish_to_docker_hub amazon/aws-for-fluent-bit
421474 elif [ " ${2} " = " us-gov-east-1" ] || [ " ${2} " = " us-gov-west-1" ]; then
422475 for region in ${gov_regions} ; do
423476 sync_latest_image ${region} ${gov_regions_account_id}
@@ -496,4 +549,4 @@ if [ "${1}" = "cicd-verify-ssm" ]; then
496549 verify_ssm ${region}
497550 done
498551 fi
499- fi
552+ fi
0 commit comments