This repository has been archived by the owner on Apr 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.sh
executable file
·83 lines (69 loc) · 1.74 KB
/
release.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
#!/usr/bin/env bash
# DESCRIPTION
# Build backoffice front-end, frontoffice front-end and
# USAGE:
# ./release.sh v1.5.6
# or
# ./release.sh
onexit(){ while caller $((n++)); do :; done; }
trap onexit EXIT
TAG="${1:-latest}"
DEFAULT_INTERFACE="${2:-ens192}"
function usage() {
printf "Usage: ./release.sh [tag]\n\n"
}
function build_frontoffice_frontend() {
cd ../daemon/frontend/
yarn build
}
function build_backoffice_frontend() {
cd ../../frontend/
yarn build
}
function build_images() {
cd ..
docker-compose build
cd daemon
docker build \
--pull \
--cache-from coaxisasp/coaxisopt_daemon \
--tag coaxisopt_daemon .
cd ..
}
# Tag all images
function tag_images() {
declare -a images=("${!1}")
tag="$2"
for image in "${images[@]}"; do
docker tag "$image" coaxisasp/"$image":"$tag"
done
}
# Push all tagged images
function push_images() {
declare -a images=("${!1}")
tag="$2"
for image in "${images[@]}"; do
docker push coaxisasp/"$image":"$tag"
done
}
function build_and_push() {
local tag="${1}"
docker_images=(
'coaxisopt_daemon'
'coaxisopt_nginx'
'coaxisopt_frontend'
'coaxisopt_backend'
)
# see http://stackoverflow.com/a/4017175/802365 and http://stackoverflow.com/a/6828383/802365
tag_images docker_images[@] "$tag"
push_images docker_images[@] "$tag"
tag_images docker_images[@] "latest"
push_images docker_images[@] "latest"
}
usage
build_frontoffice_frontend
build_backoffice_frontend
build_images
build_and_push "$TAG"
printf "\nRun\n\tdeploy/send-scripts.sh\n"
printf "\nThen, on the host machine, pull new containers releases with:\n\n\tdeploy/deploy.sh\n\n"