#!/usr/bin/env bash # The name of our algorithm algorithm_name=dnn cd container chmod +x scripts/train chmod +x scripts/serve account=$(aws sts get-caller-identity --query Account --output text) region=$(aws configure get region) fullname="${account}.dkr.ecr.${region}.amazonaws.com/${algorithm_name}:latest" echo "Pusing image to ${fullname}" # If the repository doesn't exist in ECR, create it. aws ecr describe-repositories --repository-names "${algorithm_name}" > /dev/null 2>&1 if [ $? -ne 0 ] then echo "The repository doesn't exist, we will create a new one." aws ecr create-repository --repository-name "${algorithm_name}" > /dev/null fi # Get the login command from ECR and execute it directly $(aws ecr get-login --region $region --no-include-email) echo "Successfully connected to ECR" # Build the docker image locally with the image name and then push it to ECR # with the full name. docker build -t ${algorithm_name} . docker tag ${algorithm_name} ${fullname} docker push ${fullname}