Skip to content

Commit bf319eb

Browse files
BennettJamesBennett Sala
andauthored
Deploy a multiarch image (#706)
Previously, the "main" image was always an amd64 image, and there was a secondary arm64 image that could be used with an explicit tag. This makes the amd64 image also have an explicit tag, and replaces the normal tagged image with a manifest file that will correctly route to the appropriate architecture. Co-authored-by: Bennett Sala <[email protected]>
1 parent fe56781 commit bf319eb

File tree

4 files changed

+163
-131
lines changed

4 files changed

+163
-131
lines changed

.github/actions/integration-test/action.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ runs:
5656
make test
5757
5858
- name: Configure AWS Credentials (build)
59-
uses: aws-actions/configure-aws-credentials@v1-node16
59+
uses: aws-actions/configure-aws-credentials@v2
6060
with:
6161
aws-region: us-west-2
6262
role-to-assume: ${{ inputs.aws_role }}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: "Push Image"
2+
description: "Deploys the controller image into a given region"
3+
4+
inputs:
5+
src_host:
6+
description: "URL of the source ECR repository to pull images from"
7+
required: true
8+
src_image_name:
9+
description: "Name of the source image"
10+
default: "amazon/appmesh-controller"
11+
required: false
12+
image_tag:
13+
description: "Root tag of the image to pull and push"
14+
required: true
15+
region:
16+
description: "AWS region to push images to"
17+
required: true
18+
dst_host:
19+
description: "URL of the target ECR repository to push images to"
20+
required: true
21+
dst_image_name:
22+
description: "Name of the destination image"
23+
default: "amazon/appmesh-controller"
24+
required: false
25+
role:
26+
description: "IAM role to assume to perform the deploys"
27+
required: true
28+
29+
runs:
30+
using: "composite"
31+
steps:
32+
- name: Configure AWS Credentials For Region
33+
uses: aws-actions/configure-aws-credentials@v2
34+
with:
35+
aws-region: "${{ inputs.region }}"
36+
role-to-assume: "${{ inputs.role }}"
37+
role-session-name: RegionalImageDeploy
38+
env:
39+
AWS_DEFAULT_REGION: ""
40+
AWS_REGION: ""
41+
AWS_ACCESS_KEY_ID: ""
42+
AWS_SECRET_ACCESS_KEY: ""
43+
AWS_SESSION_TOKEN: ""
44+
45+
- name: Push Images To Region
46+
shell: bash
47+
env:
48+
SRC: "${{ inputs.src_host }}/${{ inputs.src_image_name }}:${{ inputs.image_tag }}"
49+
DST: "${{ inputs.dst_host }}/${{ inputs.dst_image_name }}:${{ inputs.image_tag }}"
50+
run: |
51+
if [[ "${{ inputs.dst_host }}" =~ "public.ecr.aws" ]]; then
52+
aws ecr-public get-login-password --region "us-east-1" | \
53+
docker login --username AWS --password-stdin "public.ecr.aws"
54+
else
55+
aws ecr get-login-password --region "${{ inputs.region }}" | \
56+
docker login --username AWS --password-stdin "${{ inputs.dst_host }}"
57+
fi
58+
docker tag "${SRC}-linux_amd64" "${DST}-linux_amd64"
59+
docker push "${DST}-linux_amd64"
60+
docker tag "${SRC}-linux_arm64" "${DST}-linux_arm64"
61+
docker push "${DST}-linux_arm64"
62+
docker manifest create "$DST" "${DST}-linux_amd64" "${DST}-linux_arm64"
63+
docker manifest push "$DST"

.github/workflows/beta-release.yaml

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,8 @@ permissions:
1010
id-token: write
1111
contents: read
1212

13-
env:
14-
IMAGE_HOST: "${{ secrets.BETA_AWS_ACCOUNT }}.dkr.ecr.us-west-2.amazonaws.com"
15-
IMAGE: "${{ secrets.BETA_AWS_ACCOUNT }}.dkr.ecr.us-west-2.amazonaws.com/amazon/appmesh-controller"
16-
IMAGE_TAG: "${{ github.event.inputs.tag }}"
17-
IMAGE_TAG_AMD: "${{ github.event.inputs.tag }}-linux_amd64"
18-
IMAGE_TAG_ARM: "${{ github.event.inputs.tag }}-linux_arm64"
19-
2013
jobs:
14+
2115
integration-test:
2216
name: Integration Test
2317
runs-on: ubuntu-22.04
@@ -47,17 +41,19 @@ jobs:
4741
ref: refs/tags/${{ github.event.inputs.tag }}
4842

4943
- name: Configure AWS Credentials
50-
uses: aws-actions/configure-aws-credentials@v1-node16
44+
uses: aws-actions/configure-aws-credentials@v2
5145
with:
5246
aws-region: us-west-2
5347
role-to-assume: ${{ secrets.BETA_AWS_ROLE }}
5448
role-session-name: ImagePusher
5549

5650
- name: Build Images
51+
env:
52+
IMAGE: "${{ secrets.BETA_AWS_ACCOUNT }}.dkr.ecr.us-west-2.amazonaws.com/amazon/appmesh-controller:${{ github.event.inputs.tag }}"
5753
run: |
5854
aws ecr get-login-password --region us-west-2 | \
59-
docker login --username AWS --password-stdin $IMAGE_HOST
60-
# Note: right now, this pushes the amd image under the default. This
61-
# behavior should be changed to supporting multiarch shortly.
62-
docker buildx build --platform linux/amd64 -t "${IMAGE}:${IMAGE_TAG}" . --push
63-
docker buildx build --platform linux/arm64 -t "${IMAGE}:${IMAGE_TAG_ARM}" . --push
55+
docker login --username AWS --password-stdin "${IMAGE}"
56+
docker buildx build --platform linux/amd64 -t "${IMAGE}-linux_amd64" . --push
57+
docker buildx build --platform linux/arm64 -t "${IMAGE}-linux_arm64" . --push
58+
docker manifest create "${IMAGE}" "${IMAGE}-linux_amd64" "${IMAGE}-linux_arm64"
59+
docker manifest push "${IMAGE}"

0 commit comments

Comments
 (0)