|
2 | 2 |
|
3 | 3 | # Usage: ./docker-build.sh [tag] |
4 | 4 | # Examples: |
5 | | -# ./docker-build.sh # Uses default tag 'latest' (creates multi-arch manifest) |
6 | | -# ./docker-build.sh staging # Creates :staging-amd64, :staging-arm64, and :staging manifest |
7 | | -# ./docker-build.sh v1.2.3 # Creates :v1.2.3-amd64, :v1.2.3-arm64, and :v1.2.3 manifest |
| 5 | +# ./docker-build.sh # Uses default tag 'latest' |
| 6 | +# ./docker-build.sh staging # Creates :staging |
| 7 | +# ./docker-build.sh v1.2.3 # Creates :v1.2.3 |
8 | 8 |
|
9 | 9 | # Configuration |
10 | 10 | AWS_REGION=${AWS_REGION:-us-east-2} |
11 | 11 | ECR_REPO="633607774026.dkr.ecr.${AWS_REGION}.amazonaws.com/back-end" |
12 | 12 | TAG=${1:-latest} |
13 | 13 |
|
14 | | -echo "Building and pushing with tag: ${TAG}" |
| 14 | +echo "Building and pushing ARM64 image with tag: ${TAG}" |
15 | 15 | echo "ECR Repository: ${ECR_REPO}" |
16 | 16 |
|
17 | 17 | # Refresh AWS ECR login |
18 | 18 | echo "Refreshing AWS ECR login for region ${AWS_REGION}..." |
19 | 19 | aws ecr get-login-password --region ${AWS_REGION} | \ |
20 | 20 | docker login --username AWS --password-stdin 633607774026.dkr.ecr.${AWS_REGION}.amazonaws.com |
21 | 21 |
|
22 | | -# Build and push AMD64 image using buildx with provenance disabled |
23 | | -docker buildx build \ |
24 | | - --platform linux/amd64 \ |
25 | | - --tag ${ECR_REPO}:${TAG}-amd64 \ |
26 | | - --provenance=false \ |
27 | | - --push . |
28 | | - |
29 | 22 | # Build and push ARM64 image using buildx with provenance disabled |
30 | 23 | docker buildx build \ |
31 | 24 | --platform linux/arm64 \ |
32 | | - --tag ${ECR_REPO}:${TAG}-arm64 \ |
| 25 | + --tag ${ECR_REPO}:${TAG} \ |
33 | 26 | --provenance=false \ |
34 | 27 | --push . |
35 | 28 |
|
36 | | -# Remove existing manifest list if it exists |
37 | | -docker manifest rm ${ECR_REPO}:${TAG} || true |
38 | | - |
39 | | -# Create manifest list |
40 | | -docker manifest create \ |
41 | | - ${ECR_REPO}:${TAG} \ |
42 | | - ${ECR_REPO}:${TAG}-amd64 \ |
43 | | - ${ECR_REPO}:${TAG}-arm64 |
44 | | - |
45 | | -docker manifest inspect ${ECR_REPO}:${TAG} |
46 | | - |
47 | | -# Push the manifest |
48 | | -docker manifest push ${ECR_REPO}:${TAG} |
49 | | - |
50 | 29 | echo "" |
51 | 30 | echo "Successfully pushed: ${ECR_REPO}:${TAG}" |
0 commit comments