Last active
February 23, 2025 06:06
-
-
Save harry0805/a19fa20cd49b28ed7664b3ca16a2edbc to your computer and use it in GitHub Desktop.
Powershell script: Docker build and deploy to AWS ECR
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # By harry0805 | |
| # https://gist.github.com/harry0805/a19fa20cd49b28ed7664b3ca16a2edbc | |
| # ------------Variables-------------- | |
| # Your ECR repository name | |
| $ecr_name = "<Your-ECR-repo-name>" | |
| # Your Region | |
| $region = "us-east-1" | |
| # ----------------------------------- | |
| # Getting AWS account ID and constructing the ECR repository URI | |
| $aws_account_id = aws sts get-caller-identity --query Account --output text | |
| $ecr_repo = "$aws_account_id.dkr.ecr.$region.amazonaws.com" | |
| # Build the image using the dockerfile in the current directory | |
| docker build -t "$ecr_name`:latest" . | |
| # Tag and push | |
| docker tag "$ecr_name`:latest" "$ecr_repo/$ecr_name`:latest" | |
| aws ecr get-login-password --region $region | docker login --username AWS --password-stdin $ecr_repo | |
| docker push "$ecr_repo/$ecr_name`:latest" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment