-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_and_push.sh
64 lines (49 loc) · 1.55 KB
/
build_and_push.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# The name of our algorithm
image=$1
MODEL=$2
DATASET=$3
if [ "$image" == "" ]
then
echo "Usage: $0 <image-name>"
exit 1
fi
cd container
cp -r ../deployement .
cp -r ../pyproject.toml .
cp -r ../poetry.lock .
cp -r ../train deployement
cp -r ../src deployement/
pip install poetry
poetry export -f requirements.txt -o requirements.txt --without-hashes
python render_docker.py
chmod +x deployement/train
chmod +x deployement/serve
account=$(aws sts get-caller-identity --query Account --output text)
# Get the region defined in the current configuration (default to us-west-2 if none defined)
region=$(aws configure get region)
# specifically setting to us-east-2 since during the pre-release period, we support only that region.
region=${region:-eu-west-1}
fullname="${account}.dkr.ecr.${region}.amazonaws.com/${image}:latest"
# If the repository doesn't exist in ECR, create it.
aws ecr describe-repositories --repository-names "${image}" > /dev/null 2>&1
if [ $? -ne 0 ]
then
aws ecr create-repository --repository-name "${image}" > /dev/null
fi
# Build the docker image locally with the image name and then push it to ECR
# with the full name.
docker build --build-arg MODEL=$MODEL --build-arg DATASET=$DATASET -t ${image} .
docker tag ${image}:latest ${fullname}
aws ecr get-login-password \
--region ${region} \
| docker login \
--username AWS \
--password-stdin ${account}.dkr.ecr.${region}.amazonaws.com
docker push ${fullname}
# Cleaning
rm -r deployement
rm Dockerfile
rm requirements.txt
rm pyproject.toml
rm poetry.lock
echo ${fullname}