-
-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathupdate-pritunl-bootstrap.sh
91 lines (68 loc) · 2.01 KB
/
update-pritunl-bootstrap.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
# shellcheck shell=bash
set -o errexit -o nounset -o pipefail
function print() {
echo "${OUTPUT_PREFIX:?}" "$@"
}
function debug() {
[[ "${DEBUG:?}" -gt "0" ]] && echo "${OUTPUT_PREFIX}" "$@"
return 0
}
function debug_begin() {
debug "🚧 $*"
}
function debug_complete() {
debug "✅ $*"
}
function debug_fail() {
debug "❌ $*"
}
function action_error() {
echo -e "❌ ${RED:?}$1${NO_COLOR:?}" >&2
}
function action_error_exit() {
action_error "$1. Aborting!"
exit 1
}
function has_tag() {
[[ "${REBUILD_TAGS:?}" -eq "1" ]] && return 1
check=$(echo "${DOCKER_TAGS:?}" | grep "^$1$")
[[ "${check}" != "" ]]
}
function docker_args_reset() {
DOCKER_ARGS=()
}
function docker_args_append_tag_flags() {
local tag="$1"
DOCKER_ARGS+=(--tag "${REPO_NAME_DOCKER_HUB}:${tag}")
DOCKER_ARGS+=(--tag "ghcr.io/${REPO_NAME_GITHUB}:${tag}")
DOCKER_ARGS+=(--tag "public.ecr.aws/${REPO_NAME_ECR}:${tag}")
}
function docker_args_append_build_flags() {
local pritunl_version="$1"
local ubuntu_release="$2"
DOCKER_ARGS+=(--pull)
DOCKER_ARGS+=(--push)
DOCKER_ARGS+=(--builder "${DOCKER_BUILDX_NAME:?}")
DOCKER_ARGS+=(--sbom true)
DOCKER_ARGS+=(--attest "type=provenance,mode=max")
DOCKER_ARGS+=(--platform "$(array::join "," "${BUILD_PLATFORMS[@]}")")
DOCKER_ARGS+=(--cache-from "type=local,src=${DOCKER_CACHE_FOLDER:?}")
DOCKER_ARGS+=(--cache-to "type=local,dest=${DOCKER_CACHE_FOLDER:?}")
if [[ "${DEBUG}" == "0" ]]; then
DOCKER_ARGS+=(--quiet)
else
DOCKER_ARGS+=(--progress plain)
fi
DOCKER_ARGS+=(--build-arg "BUILD_DATE=${BUILD_DATE:?}")
DOCKER_ARGS+=(--build-arg "PRITUNL_VERSION=${pritunl_version}")
DOCKER_ARGS+=(--build-arg "UBUNTU_RELEASE=${ubuntu_release}")
}
function docker_args_without_mongodb() {
DOCKER_ARGS+=(--build-arg=MONGODB_VERSION=no)
}
function array::join() {
local separator="$1"
shift
joined=$(printf "${separator}%s" "$@")
echo "${joined#"${separator}"}"
}