-
Notifications
You must be signed in to change notification settings - Fork 63
/
update-pritunl.sh
executable file
·130 lines (102 loc) · 4.5 KB
/
update-pritunl.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
#!/usr/bin/env bash
set -o errexit -o nounset -o pipefail
########################################################################
# Load libraries
########################################################################
source "update-pritunl-config.sh"
source "update-pritunl-bootstrap.sh"
source "update-pritunl-setup.sh"
########################################################################
# Build docker images
########################################################################
debug "github tags: $(echo "${pritunl_releases:?}" | xargs || true)"
debug "latest tag will be ${latest_release:?}"
for pritunl_release in ${pritunl_releases}; do
OUTPUT_PREFIX="[build/${pritunl_release}/default]"
debug "Considering release"
if [[ -n "${SKIP[${pritunl_release}]+skip}" ]]; then
print "🚫 Skipping: ${SKIP[${pritunl_release}]}"
continue
fi
# loop over ubuntu releases we support
for ubuntu_release in "${UBUNTU_RELEASES[@]}"; do
tag=${pritunl_release}
suffix=""
# change docker tag if we're not building bionic
if [[ "${ubuntu_release}" != "${DEFAULT_UBUNTU_RELEASE}" ]]; then
suffix="-${ubuntu_release}"
tag="${tag}${suffix}"
fi
OUTPUT_PREFIX="[build/${pritunl_release}/${ubuntu_release}/default]"
debug "👷 Processing"
####################################################################################
# build without mongo ("minimal" tag)
####################################################################################
OUTPUT_PREFIX="[build/${pritunl_release}/${ubuntu_release}/minimal]"
debug "👷 Processing"
tag+="-minimal"
# shellcheck disable=SC2310
if ! has_tag "${tag}"; then
docker_args_reset
docker_args_append_build_flags "${pritunl_release}" "${ubuntu_release}"
docker_args_without_mongodb
docker_args_append_tag_flags "${tag}"
if [[ "${pritunl_release}" == "${latest_release}" ]]; then
OUTPUT_PREFIX="[build/${pritunl_release}/${ubuntu_release}/minimal/latest]"
print "🏷️ Tagging as latest"
docker_args_append_tag_flags "latest${suffix}-minimal"
fi
debug "Building with tags: [${DOCKER_ARGS[*]}]"
print "🚧 Building container image"
start=${SECONDS}
docker buildx build "${DOCKER_ARGS[@]}" "."
diff=$((SECONDS - start))
duration=$(date -ud "@${diff}" "+%H:%M:%S")
print "✅ Done in ${duration}"
else
print "✅ Already build"
fi
done
####################################################################################
# build with mongo (default container)
####################################################################################
# shellcheck disable=SC2310
if ! has_tag "${tag}"; then
if ! supports_mongodb "${ubuntu_release}"; then
print "🚫 Skipping: ${ubuntu_release} does not support MongoDB"
continue
fi
docker_args_reset
docker_args_append_build_flags "${pritunl_release}" "${ubuntu_release}"
docker_args_append_tag_flags "${tag}"
if [[ "${pritunl_release}" == "${latest_release}" ]]; then
OUTPUT_PREFIX="[build/${pritunl_release}/${ubuntu_release}/default/latest]"
print "🏷️ Tagging as latest"
docker_args_append_tag_flags "latest${suffix}"
fi
print "🚧 Building container image"
start=${SECONDS}
docker buildx build "${DOCKER_ARGS[@]}" "."
diff=$((SECONDS - start))
duration=$(date -ud "@${diff}" "+%H:%M:%S")
print "✅ Done in ${duration}"
else
print "✅ Already build"
fi
done
if [[ "${DEBUG:?}" != "0" ]]; then
debug_complete "Not flushing caches in debug mode"
exit 0
fi
print "🚧 Pruning buildx caches"
docker buildx inspect --bootstrap "${DOCKER_BUILDX_NAME:?}" >/dev/null && docker buildx prune --all --force --builder "${DOCKER_BUILDX_NAME:?}"
print "✅ Done"
if [[ -d "${DOCKER_CACHE_FOLDER:?}/ingest" ]]; then
print "🚧 Pruning buildx exports"
rm -rf -v "${DOCKER_CACHE_FOLDER:?}"
print "✅ Done"
fi
# This might not be needed in once https://github.com/moby/moby/releases/tag/v26.0.0-rc2 is released!
print "🚧 Removing buildx builder to free up disk space"
docker buildx rm --force --builder "${DOCKER_BUILDX_NAME:?}" || :
print "✅ Done"