Created
May 27, 2022 10:35
-
-
Save ndamulelonemakh/166f835edbd05db14a88d52e954d7d6a to your computer and use it in GitHub Desktop.
Misc scripts for building and publishing containers
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
| #!/bin/bash | |
| IMAGE_TAG=ecr_repo_name | |
| ECR_URL=public.ecr.aws/<your-ec-id> | |
| REGION=east-us-1 | |
| # setup aws cli | |
| # Reference: https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html | |
| curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" | |
| unzip awscliv2.zip | |
| sudo ./aws/install | |
| # aws cli profile setup | |
| # Get new access key/secret from users menu on aws console | |
| aws configure | |
| # setup docker(if not installed already) | |
| # reference: https://docs.docker.com/engine/install/ubuntu/ | |
| curl -fsSL https://get.docker.com -o get-docker.sh | |
| sudo sh get-docker.sh | |
| # login to your ecr | |
| aws ecr-public get-login-password --region $REGION | docker login --username AWS --password-stdin $ECR_URL | |
| # build your image | |
| DOCKER_BUILDKIT=1 docker built -t $IMAGE_TAG . | |
| # tag it | |
| docker tag $IMAGE_TAG :latest $ECR_URL/$IMAGE_TAG:latest | |
| # push it | |
| docker push $ECR_URL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment