-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
executable file
·102 lines (82 loc) · 1.94 KB
/
docker-entrypoint.sh
File metadata and controls
executable file
·102 lines (82 loc) · 1.94 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
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
#!/bin/bash
# fail fast
set -e
function wait_for_host_port {
if [[ $# != 2 ]]; then echo "usage: $FUNCNAME host port"; return 1; fi
host=$1
port=$2
echo "Waiting for $host:$port to become available"
while ! nc -z $host $port > /dev/null 2>&1; do echo .; sleep 2; done
echo "The service on $host:$port is now available"
}
function wait_for_services {
for svc in $SERVICES; do
host=${svc%%:*}
port=${svc##*:}
wait_for_host_port ${!host} ${!port}
done
}
function app_init {
# # Run bundler if needed - useful in dev
# if [[ "$APP_ENV" == "development" ]]; then
# npm install
# fi
:
}
export -f app_init
action=$1; shift
case $action in
compile)
wait_for_services
app_init
npm run compile
;;
deploy)
wait_for_services
app_init
if [[ -n $ABI_BUCKET ]]; then
# Truffle migrations store state in a contract, but need to read
# Migration.json to find the contract, so pull in most recent json files
# from abi bucket as they only get written there if the deploy was
# successful
echo "Importing $ABI_BUCKET contents to allow incremental migrations"
aws s3 cp --recursive \
s3://$ABI_BUCKET/ build/
fi
if [[ "$PARITY_CHAIN" == "mainnet" ]]; then
echo "Deploying to mainnet"
npm run deploy:mainnet
elif [[ "$PARITY_CHAIN" == "kovan" ]]; then
echo "Deploying to kovan"
npm run deploy:kovan
else
echo "Deploying to development"
npm run deploy:development
fi
if [[ -n $ABI_BUCKET ]]; then
echo "Copying ABI to $ABI_BUCKET"
aws s3 cp --acl bucket-owner-full-control --recursive \
build/ s3://$ABI_BUCKET/
fi
;;
console)
wait_for_services
app_init
truffle console
;;
test)
wait_for_services
npm run compile
npm run test:truffle
;;
bash)
exec bash -il
;;
exec)
exec "$@"
;;
*)
echo "Invalid action: $action"
exit 1
;;
esac