Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

ecr.sh 1.2 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
  1. #!/bin/bash
  2. set -euo pipefail
  3. # Load environment variables
  4. if [ ! -f .env ]; then
  5. echo ".env file not found!"
  6. exit 1
  7. fi
  8. set -a
  9. source .env
  10. set +a
  11. # Get AWS Account ID
  12. ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
  13. ECR_URI="${ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com/${ECR_REPO_NAME}"
  14. echo "Using ECR URI: $ECR_URI"
  15. # Authenticate Docker to ECR
  16. aws ecr get-login-password --region "$AWS_REGION" | docker login --username AWS --password-stdin "$ECR_URI"
  17. # Create ECR repository if it doesn't exist
  18. if ! aws ecr describe-repositories --repository-names "$ECR_REPO_NAME" --region "$AWS_REGION" > /dev/null 2>&1; then
  19. echo "Creating ECR repository: $ECR_REPO_NAME"
  20. aws ecr create-repository --repository-name "$ECR_REPO_NAME" --region "$AWS_REGION"
  21. fi
  22. # Ensure buildx builder exists and is in use
  23. if ! docker buildx inspect multi-builder > /dev/null 2>&1; then
  24. docker buildx create --name multi-builder --use
  25. fi
  26. docker buildx use multi-builder
  27. # Build and push multi-platform image (amd64 + arm64)
  28. docker buildx build --platform linux/amd64 \
  29. -t "${ECR_URI}:${IMAGE_TAG}" \
  30. --push .
  31. echo "Multi-arch image pushed to: ${ECR_URI}:${IMAGE_TAG}"
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...