-
Notifications
You must be signed in to change notification settings - Fork 35
/
docker-push.sh
executable file
·111 lines (88 loc) · 2.28 KB
/
docker-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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/bin/bash
#--- ARGS
BUILD_ENV=$1
#--- FUNCTIONS
function tag {
BUILD_ENV=$1
case $BUILD_ENV in
"qa")
echo latest
;;
"prod")
echo release
;;
*)
echo "ERROR: don't know what to do with BUILD_ENV: "$BUILD_ENV""
exit 1
;;
esac
}
function build {
{
NAME=$1
BUILD_ENV=$2
VERSION=$(git log -1 --pretty=%h)
TAG=$(tag $BUILD_ENV)
IMG=$NAME:$VERSION
export SMART_CONTRACTS=./src/memefactory/shared/smart_contracts_${BUILD_ENV}.cljs
export SMART_CONTRACTS_BUILD_PATH=./resources/public/contracts/build/
echo "Current directory ${PWD}"
SERVICE=$(echo $NAME | cut -d "-" -f 2)
echo "============================================================="
echo "["$BUILD_ENV"] ["$SERVICE"] Buidling: "$IMG" with tag "$TAG""
echo "============================================================="
case $SERVICE in
"ui")
# lein garden once
# env MEMEFACTORY_ENV=$BUILD_ENV lein cljsbuild once "ui"
# env MEMEFACTORY_ENV=$BUILD_ENV
echo "building UI"
;;
"server")
# env MEMEFACTORY_ENV=$BUILD_ENV lein cljsbuild once "server"
echo "building server"
;;
*)
echo "ERROR: don't know what to do with SERVICE: "$SERVICE""
exit 1
;;
esac
echo "Running: docker build -t $IMG --build-arg build_environment=$BUILD_ENV -f docker-builds/$SERVICE/Dockerfile ."
docker build -t $IMG --build-arg build_environment=$BUILD_ENV -f docker-builds/$SERVICE/Dockerfile .
docker tag $IMG $NAME:$TAG
} || {
echo "EXCEPTION WHEN BUIDLING "$IMG""
exit 1
}
}
function push {
NAME=$1
BUILD_ENV=$2
TAG=$(tag $BUILD_ENV)
echo "============================================================="
echo "Pushing "$NAME" : "$TAG" "
echo "============================================================="
docker push $NAME:$TAG
}
function login {
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
}
# function before {
# lein deps
# yarn deps
# truffle compile
# }
#--- EXECUTE
# before
# login
images=(
district0x/memefactory-server
district0x/memefactory-ui
)
for i in "${images[@]}"; do
(
build $i $BUILD_ENV
# push $i $BUILD_ENV
)
done # END: i loop
exit $?