forked from bee-software/shipper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ship.sh
executable file
·57 lines (44 loc) · 1.43 KB
/
ship.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
#!/bin/bash
set -e
set -o pipefail
DRY_RUN="${DRY_RUN:-"0"}"
source $(dirname $0)/src/config.sh
source $(dirname $0)/src/remote.sh
source $(dirname $0)/src/templating.sh
source $(dirname $0)/src/docker_ready.sh
source $(dirname $0)/src/docker_images.sh
source $(dirname $0)/src/docker_compose.sh
source $(dirname $0)/src/shipping.sh
source $(dirname $0)/src/hooks.sh
source $(dirname $0)/src/secrets.sh
source $(dirname $0)/src/versioning.sh
fail() {
echo $@ > /dev/stderr
exit 1
}
run() {
if [ ${DRY_RUN} == "1" ]; then
: "${@}"
else
"${@}"
fi
}
ship() {
local shipping_label=${1}; shift
local options=${*:-}
local compose_file="$(compose_file_from_label ${shipping_label})"
[ -f ${compose_file} ] || fail "Missing docker-compose.yml file in shipping label (${shipping_label})."
shipping_summary ${shipping_label} ${DRY_RUN} ${options}
if is_shipping_label_audited ${shipping_label}; then
run write_version_file_for ${shipping_label} ${compose_file} ${options}
fi
local destination="$(destination_from_label ${shipping_label})"
run pre_deploy_on_host_hooks "${shipping_label}"
run docker_ready "${destination}"
run remove_unused_images "${destination}"
run load_compose_file ${shipping_label} ${options}
run bring_up_containers ${shipping_label}
run send_secrets ${shipping_label}
run post_deploy_on_host_hooks "${shipping_label}"
}
ship "${@}"