forked from dbca-wa/licensing-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmake_docker_image.sh
More file actions
executable file
·31 lines (28 loc) · 893 Bytes
/
make_docker_image.sh
File metadata and controls
executable file
·31 lines (28 loc) · 893 Bytes
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
#!/bin/bash
## first parameter is DBCA branch name
set -e
if [[ $# -lt 1 ]]; then
echo "ERROR: DBCA branch must be specified"
echo "$0 1"
exit 1
fi
REPO_NO_DASH=$(awk '{n=split($0, arr, "\\/"); print arr[n]}' <<< $(git config -l|grep remote|grep url|head -n 1|sed 's/-//g'|sed 's/....$//'))
REPO=$(awk '{n=split($0, arr, "\\/"); print arr[n]}' <<< $(git config -l|grep remote|grep url|head -n 1|sed 's/....$//'))
# Docker repo may be named differently to github repo
BUILD_TAG=dbcawa/$REPO_NO_DASH:$1_v$(date +%Y.%m.%d.%H.%M%S)
{
docker image build --build-arg REPO_ARG=$REPO --build-arg REPO_NO_DASH_ARG=$REPO_NO_DASH --build-arg BRANCH_ARG=$1 --no-cache --tag $BUILD_TAG . &&
echo $BUILD_TAG
} ||
{
echo "ERROR: Docker build failed"
echo "$0 1"
exit 1
}
{
docker push $BUILD_TAG
} || {
echo "ERROR: Docker push failed"
echo "$0 1"
exit 1
}