-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·36 lines (27 loc) · 892 Bytes
/
build.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
#!/bin/bash
set -ex
if ! [ -x "$(command -v docker)" ]; then
echo "docker command is not found"
exit 1
fi
if ! [ -x "$(command -v aws)" ]; then
echo "aws CLI is not found"
exit 1
fi
if [ -z $ACCOUNT ]; then
echo "ACCOUNT environment variable is not set"
exit 1
fi
if [ -z $REGION ]; then
echo "REGION environment variable is not set"
exit 1
fi
IMG=${IMG:-amazon/kinesis-kafka-connector}
VER=${VER:-snapshot-0.0.9}
REPO=$ACCOUNT.dkr.ecr.$REGION.amazonaws.com
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
docker build -t $REPO/$IMG:$VER --rm $DIR
docker rmi $(docker images -f "dangling=true" -q) || true # remove intermediate images in build stage, optional
aws ecr get-login-password --region $REGION \
| docker login --username AWS --password-stdin $REPO # assume the repository exists already
docker push $REPO/$IMG:$VER