-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathpublish-docker-image.sh
More file actions
executable file
·51 lines (40 loc) · 1.61 KB
/
publish-docker-image.sh
File metadata and controls
executable file
·51 lines (40 loc) · 1.61 KB
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
#!/usr/bin/env bash
set -e
set -o pipefail
usage()
{
echo "usage: publish-docker-image.sh
--repository the target repository to upload the Docker image, example:
gcr.io/kf-feast/feast-core
--tag the tag for the Docker image, example: 1.0.4
--file path to the Dockerfile
[--google-service-account-file
path to Google Cloud service account JSON key file]
"
}
while [ "$1" != "" ]; do
case "$1" in
--repository ) REPOSITORY="$2"; shift;;
--tag ) TAG="$2"; shift;;
--file ) FILE="$2"; shift;;
--google-service-account-file ) GOOGLE_SERVICE_ACCOUNT_FILE="$2"; shift;;
-h | --help ) usage; exit;;
* ) usage; exit 1
esac
shift
done
if [ -z $REPOSITORY ]; then usage; exit 1; fi
if [ -z $TAG ]; then usage; exit 1; fi
if [ -z $FILE ]; then usage; exit 1; fi
if [ $GOOGLE_SERVICE_ACCOUNT_FILE ]; then
gcloud -q auth activate-service-account --key-file $GOOGLE_SERVICE_ACCOUNT_FILE
gcloud -q auth configure-docker
fi
echo "============================================================"
echo "Building Docker image $REPOSITORY:$TAG"
echo "============================================================"
docker build -t $REPOSITORY:$TAG --build-arg REVISION=$TAG -f $FILE .
echo "============================================================"
echo "Pushing Docker image $REPOSITORY:$TAG"
echo "============================================================"
docker push $REPOSITORY:$TAG