version: 0.2 phases: install: runtime-versions: python: 3.8 pre_build: commands: - echo Logging in to Amazon ECR... - export AWS_ACCOUNT=$(aws sts get-caller-identity | jq -r '.Account') - echo "AWS_ACCOUNT is $AWS_ACCOUNT" - aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT.dkr.ecr.$AWS_REGION.amazonaws.com build: commands: - echo Build started on `date` - echo Building the Docker image... - echo "IMAGE_REPO_NAME is $IMAGE_REPO_NAME" - docker build -t $IMAGE_REPO_NAME . - docker tag $IMAGE_REPO_NAME:latest $AWS_ACCOUNT.dkr.ecr.$AWS_REGION.amazonaws.com/$IMAGE_REPO_NAME:latest post_build: commands: - echo Build completed on `date` - echo Pushing the Docker image... - docker push $AWS_ACCOUNT.dkr.ecr.$AWS_REGION.amazonaws.com/$IMAGE_REPO_NAME:latest