generated from NethServer/ns8-kickstart
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuild-images.sh
155 lines (129 loc) · 4.39 KB
/
build-images.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#!/bin/bash
# Terminate on error
set -e
# Prepare variables for later use
images=()
# The image will be pushed to GitHub container registry
repobase="${REPOBASE:-ghcr.io/nethesis}"
# Configure the image name
reponame="nethvoice"
# Build NS8 Module image
buildah build \
--force-rm \
--layers \
--jobs "$(nproc)" \
--build-arg REPOBASE="${repobase}" \
--build-arg IMAGETAG="${IMAGETAG:-latest}" \
--target dist \
--tag "${repobase}/${reponame}" \
--tag "${repobase}/${reponame}:${IMAGETAG:-latest}" \
# Append the image URL to the images array
images+=("${repobase}/${reponame}")
#######################
## MariaDB ##
#######################
echo "[*] Build mariadb container"
reponame="nethvoice-mariadb"
container=$(buildah from docker.io/library/mariadb:10.8.2)
buildah add "${container}" mariadb/ /
# Commit the image
buildah commit "${container}" "${repobase}/${reponame}"
buildah commit "${container}" "${repobase}/${reponame}:${IMAGETAG:-latest}"
# Append the image URL to the images array
images+=("${repobase}/${reponame}")
##########################
## FreePBX 16 ##
##########################
echo "[*] Build FreePBX container"
reponame="nethvoice-freepbx"
pushd freepbx
buildah build --force-rm --no-cache --jobs "$(nproc)" \
--tag "${repobase}/${reponame}" \
--tag "${repobase}/${reponame}:${IMAGETAG:-latest}"
popd
# Append the image URL to the images array
images+=("${repobase}/${reponame}")
########################
## Tancredi ##
########################
echo "[*] Build Tancredi container"
reponame="nethvoice-tancredi"
pushd tancredi
buildah build --force-rm --layers --jobs "$(nproc)" \
--tag "${repobase}/${reponame}" \
--tag "${repobase}/${reponame}:${IMAGETAG:-latest}"
popd
# Append the image URL to the images array
images+=("${repobase}/${reponame}")
#############################
## NethCTI Server ##
#############################
echo "[*] Build nethcti container"
reponame="nethvoice-cti-server"
pushd nethcti-server
buildah build --force-rm --layers --jobs "$(nproc)" --target production \
--tag "${repobase}/${reponame}" \
--tag "${repobase}/${reponame}:${IMAGETAG:-latest}"
popd
# Append the image URL to the images array
images+=("${repobase}/${reponame}")
#############################
## NethCTI Client ##
#############################
reponame="nethvoice-cti-ui"
container=$(buildah from ghcr.io/nethesis/nethvoice-cti:0.3.2)
# Commit the image
buildah commit "${container}" "${repobase}/${reponame}"
buildah commit "${container}" "${repobase}/${reponame}:${IMAGETAG:-latest}"
# Append the image URL to the images array
images+=("${repobase}/${reponame}")
#############################
## Janus Gateway ##
#############################
echo "[*] Build Janus Gateway container"
reponame="nethvoice-janus"
pushd janus
buildah build --force-rm --layers --jobs "$(nproc)" \
--tag "${repobase}/${reponame}" \
--tag "${repobase}/${reponame}:${IMAGETAG:-latest}"
popd
# Append the image URL to the images array
images+=("${repobase}/${reponame}")
#########################
## Phonebook ##
#########################
echo "[*] Build Phonebook container"
reponame="nethvoice-phonebook"
pushd phonebook
buildah build --force-rm --layers --jobs "$(nproc)" \
--tag "${repobase}/${reponame}" \
--tag "${repobase}/${reponame}:${IMAGETAG:-latest}"
popd
# Append the image URL to the images array
images+=("${repobase}/${reponame}")
#########################
## Reports ##
#########################
pushd reports
reponame="nethvoice-reports-api"
buildah build --force-rm --layers --jobs "$(nproc)" --target api-production \
--tag "${repobase}"/"${reponame}" \
--tag "${repobase}"/"${reponame}:${IMAGETAG:-latest}"
images+=("${repobase}/${reponame}")
reponame="nethvoice-reports-ui"
buildah build --force-rm --layers --jobs "$(nproc)" --target ui-production \
--tag "${repobase}"/"${reponame}" \
--tag "${repobase}"/"${reponame}:${IMAGETAG:-latest}"
images+=("${repobase}/${reponame}")
popd
# Setup CI when pushing to Github.
# Warning! docker::// protocol expects lowercase letters (,,)
if [[ -n "${CI}" ]]; then
# Set output value for Github Actions
printf "::set-output name=images::%s\n" "${images[*]}"
else
# Just print info for manual push
printf "Publish the images with:\n\n"
for image in "${images[@],,}"; do printf " buildah push %s docker://%s:%s\n" "${image}" "${image}" "${IMAGETAG:-latest}" ; done
printf "\n"
fi