in hack/images/migrate_ecr.py [0:0]
def process_images():
"""Read images from file, check/create repos, and push images to ECR."""
login_to_ecr()
with open(IMAGES_FILE_PATH, 'r') as file:
for line in file:
source_image = line.strip()
if source_image:
# Extract repo path and tag (e.g., 'alpine/curl' from 'docker.io/alpine/curl:3.14')
repo_path = '/'.join(source_image.split('/')[1:]).split(':')[0]
tag = source_image.split(':')[-1]
# Define ECR repository name and full ECR image path
repo_name = repo_path
ecr_image = f"{AWS_ACCOUNT_ID}.dkr.ecr.{AWS_REGION}.amazonaws.com/{repo_name}:{tag}"
# Check if the repository exists, if not, create it
if not ecr_repository_exists(repo_name):
create_ecr_repository(repo_name)
# Push the image to ECR
push_image_to_ecr(source_image, ecr_image)