Push image and charts to AWS ECR
Here is complete example of building and pushing image to AWS ECR repo. Also example of how to push your helm charts to ECR repo.
I will be using Podman for this build activities.
Pre-requisites
- ECR repo created
- AWS profile/Auth with write access to repo.
Build and push image to ECR
Build your image locally with aws repo tag. My ECR is called myapp
podman build --arch amd64 . -t <aws_account_id>.dkr.ecr.eu-west-2.amazonaws.com/myapp:v0.1.0 .
# Get ECR credentials and log on to ECR with Podman. Here I am using AWS profile called labs
aws ecr get-login-password --profile labs --region eu-west-2 | podman login --username AWS --password-stdin <aws_account_id>.dkr.ecr.eu-west-2.amazonaws.com
# Run the following command to push this image to your repository
podman push <aws_account_id>.dkr.ecr.eu-west-2.amazonaws.com/myapp:v0.1.0
Push Helm chart to ECR repo
In this example I have a Helm repo in ECR calles myapp-helm
Steps as follows
# Create helm chart
helm create myapp-helm .
# Once updated, create helm chart package
helm package myapp-helm # This will create packaged chart file myapp-helm-<chart-version>
[!WARNING] When pushing image, only OCI repo URL provided, repo name and version extracted from package name
# Authenticate Helm to ECR repo
aws ecr get-login-password --profile labs --region eu-west-2 | helm login --username AWS --password-stdin <aws_account_id>.dkr.ecr.eu-west-2.amazonaws.com
# Push chart to ECR repo
helm push myapp-helm-0.3.0.tgz oci:// <aws_account_id>.dkr.ecr.eu-west-2.amazonaws.com/myapp-helm
# *** Note that URL is OCI and only URL to OCI repo provided. Repo name and version are extracted from package name.