-
Notifications
You must be signed in to change notification settings - Fork 181
Expand file tree
/
Copy pathcreate.sh
More file actions
executable file
·63 lines (49 loc) · 1.59 KB
/
Copy pathcreate.sh
File metadata and controls
executable file
·63 lines (49 loc) · 1.59 KB
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
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)"
export_image() {
local name=$1
local image=$2
local last_dir=$3
docker pull "$image" | cat
mkdir -p "${DIR}/${last_dir}"
echo "Saving $image to ${DIR}/${last_dir}/${name}.img"
docker save "$image" -o "${DIR}/${last_dir}/${name}.img"
}
save() {
local registry=$1
local name=$2
local tag=$3
local last_dir=$4
export_image "$name" "${registry}/${name}:${tag}" "${last_dir}"
}
bundle() {
local name=$1
pushd "${DIR}"
tar -czvf "${name}.tgz" "${name}"
popd
}
store_roxctl() {
output_path=$1
mkdir -p "${DIR}/${output_path}/bin"
gsutil -m cp -r "gs://sr-roxc/${main_tag}/bin/darwin" "${DIR}/${output_path}/bin"
gsutil -m cp -r "gs://sr-roxc/${main_tag}/bin/linux" "${DIR}/${output_path}/bin"
gsutil -m cp -r "gs://sr-roxc/${main_tag}/bin/windows" "${DIR}/${output_path}/bin"
chmod +x "${DIR}/${output_path}/bin/darwin/roxctl" "${DIR}/${output_path}/bin/linux/roxctl"
}
main() {
# Main uses the version reported by make tag.
local main_tag
main_tag="$(make --quiet --no-print-directory tag)"
save "stackrox.io" "main" "${main_tag}" "image-bundle"
# Scanner uses the same version as Main.
save "stackrox.io" "scanner" "${main_tag}" "image-bundle"
save "stackrox.io" "scanner-db" "${main_tag}" "image-bundle"
# Collector uses the same version as Main.
save "collector.stackrox.io" "collector" "${main_tag}" "image-collector-bundle"
store_roxctl "image-bundle"
bundle "image-bundle"
bundle "image-collector-bundle"
}
main "$@"