forked from harryi3t/box
-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.sh
executable file
·45 lines (38 loc) · 1.11 KB
/
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
37
38
39
40
41
42
43
44
45
#!/bin/bash -e
export BRANCH=master
export IMAGE_NAME=avinci/box
export IMAGE_TAG=$BRANCH.$BUILD_NUMBER
export RES_DOCKER_CREDS=docker-creds
export RES_BOX_REPO=box-repo
export RES_BOX_IMAGE=box-img
dockerBuild() {
echo "Starting Docker build for" $IMAGE_NAME:$IMAGE_TAG
cd ./IN/$RES_BOX_REPO/gitRepo
sudo docker build -t=$IMAGE_NAME:$IMAGE_TAG .
echo "Completed Docker build for" $IMAGE_NAME:$IMAGE_TAG
}
dockerPush() {
echo "Starting Docker push for" $IMAGE_NAME:$IMAGE_TAG
sudo docker push $IMAGE_NAME:$IMAGE_TAG
echo "Completed Docker push for" $IMAGE_NAME:$IMAGE_TAG
}
dockerLogin() {
echo "Extracting docker creds"
. ./IN/$RES_DOCKER_CREDS/integration.env
echo "logging into Docker with username" $username
docker login -u $username -p $password -e $email
echo "Completed Docker login"
}
createOutState() {
echo "Creating a state file for" $RES_BOX_IMAGE
echo versionName=$IMAGE_TAG > /build/state/$RES_BOX_IMAGE.env
cat /build/state/$RES_BOX_IMAGE.env
echo "Completed creating a state file for" $RES_BOX_IMAGE
}
main() {
dockerLogin
dockerBuild
dockerPush
createOutState
}
main