Skip to content

Commit 61ae19f

Browse files
committed
tag image a different way
1 parent 03a0bd7 commit 61ae19f

File tree

2 files changed

+24
-14
lines changed

2 files changed

+24
-14
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
{
44
"name": "Ubuntu",
55
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6+
"image": "foo",
67
"build": {
78
"dockerfile": "Dockerfile",
89
"context": "..",

.github/workflows/tag_latest_dev_container.yml

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -67,23 +67,32 @@ jobs:
6767
ACCOUNT_ID: ${{ steps.retrieve-deploy-account-id.outputs.account_id }}
6868
VERSION_TAG_TO_APPLY: ${{ inputs.version_tag_to_apply }}
6969
run: |
70-
# Tag the image (this creates an alias without pulling)
71-
docker tag "${ACCOUNT_ID}.dkr.ecr.eu-west-2.amazonaws.com/${ECR_REPOSITORY}:${IMAGE_TAG}-amd64" \
72-
"${ACCOUNT_ID}.dkr.ecr.eu-west-2.amazonaws.com/${ECR_REPOSITORY}:${VERSION_TAG_TO_APPLY}-amd64"
73-
docker tag "${ACCOUNT_ID}.dkr.ecr.eu-west-2.amazonaws.com/${ECR_REPOSITORY}:${IMAGE_TAG}-arm64" \
74-
"${ACCOUNT_ID}.dkr.ecr.eu-west-2.amazonaws.com/${ECR_REPOSITORY}:${VERSION_TAG_TO_APPLY}-arm64"
70+
# Get the image manifest
71+
MANIFEST=$(aws ecr batch-get-image \
72+
--repository-name "${ECR_REPOSITORY}" \
73+
--image-ids imageTag="${IMAGE_TAG}-amd64" \
74+
--output text --query 'images[].imageManifest')
7575
76-
docker tag "${ACCOUNT_ID}.dkr.ecr.eu-west-2.amazonaws.com/${ECR_REPOSITORY}:${IMAGE_TAG}-amd64" \
77-
"${ACCOUNT_ID}.dkr.ecr.eu-west-2.amazonaws.com/${ECR_REPOSITORY}:latest-amd64"
78-
docker tag "${ACCOUNT_ID}.dkr.ecr.eu-west-2.amazonaws.com/${ECR_REPOSITORY}:${IMAGE_TAG}-arm64" \
79-
"${ACCOUNT_ID}.dkr.ecr.eu-west-2.amazonaws.com/${ECR_REPOSITORY}:latest-arm64"
76+
# Put the image with a new tag using the same manifest
77+
aws ecr put-image --repository-name "${ECR_REPOSITORY}" \
78+
--image-manifest "$MANIFEST" \
79+
--image-tag "${VERSION_TAG_TO_APPLY}-amd64"
80+
aws ecr put-image --repository-name "${ECR_REPOSITORY}" \
81+
--image-manifest "$MANIFEST" \
82+
--image-tag latest-amd64
8083
81-
# Push the new tags
82-
docker push "${ACCOUNT_ID}.dkr.ecr.eu-west-2.amazonaws.com/${ECR_REPOSITORY}:${VERSION_TAG_TO_APPLY}-amd64"
83-
docker push "${ACCOUNT_ID}.dkr.ecr.eu-west-2.amazonaws.com/${ECR_REPOSITORY}:${VERSION_TAG_TO_APPLY}-arm64"
84+
MANIFEST=$(aws ecr batch-get-image \
85+
--repository-name "${ECR_REPOSITORY}" \
86+
--image-ids imageTag="${IMAGE_TAG}-arm64" \
87+
--output text --query 'images[].imageManifest')
8488
85-
docker push "${ACCOUNT_ID}.dkr.ecr.eu-west-2.amazonaws.com/${ECR_REPOSITORY}:latest-amd64"
86-
docker push "${ACCOUNT_ID}.dkr.ecr.eu-west-2.amazonaws.com/${ECR_REPOSITORY}:latest-arm64"
89+
# Put the image with a new tag using the same manifest
90+
aws ecr put-image --repository-name "${ECR_REPOSITORY}" \
91+
--image-manifest "$MANIFEST" \
92+
--image-tag "${VERSION_TAG_TO_APPLY}-arm64"
93+
aws ecr put-image --repository-name "${ECR_REPOSITORY}" \
94+
--image-manifest "$MANIFEST" \
95+
--image-tag latest-arm64
8796
8897
- name: Verify multi-architecture manifest
8998
env:

0 commit comments

Comments
 (0)