-
Notifications
You must be signed in to change notification settings - Fork 84
/
Copy pathhelpers
62 lines (56 loc) · 1.83 KB
/
helpers
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
# Ruby builder helper functions
#
function print_usage_and_exit() {
echo
echo "This is the Ruby/Rails self-contained builder image."
echo "You can use this to produce application images:"
echo
echo " $ docker run -v \$(pwd):/tmp/src openshift/centos-ruby-builder"
echo
echo "You can also archive artifacts from the current application image:"
echo
echo " $ docker run --entrypoint='${HOME}/bin/save-artifacts' ruby-app > archive.tgz"
echo
echo "And restore the artifacts on the next build:"
echo
echo " $ docker run -v \$(pwd):/tmp/src openshift/centos-ruby-builder < archive.tgz"
echo
echo "Other options:"
echo
echo " -s <URL> Point builder to remote directory with assemble scripts"
echo " -h Print this usage"
echo " -d Drop to the shell instead of build."
echo
exit 0
}
# Functions to support downloading/replacing the base image scripts.
# Users could override them by:
#
# 1) Adding them into GIT_SOURCE/.sti/ folder
# 1) Using '-s URL' on the builder command line
function download_script() {
local url="$1"
local script_name="$2"
if ! curl --silent -L "${url}/${script_name}" > ${HOME}/bin/${script_name}; then
echo "Warning: Unable to download '${url}/${script_name}' ($?)"
fi
}
function copy_script() {
local $script_name="$1"
[ ! -f "/tmp/src/.sti/${script_name}"] && return
cp -f "/tmp/src/.sti/${script_name}" "${HOME}/bin/${script_name}" && \
chmod +x "${HOME}/bin/${script_name}"
}
function download_assemble_scripts() {
# FIXME: Rename 'prepare' to 'assemble' at some point.
download_script "$1" "prepare"
download_script "$1" "save-artifacts"
download_script "$1" "restore-artifacts"
download_script "$1" "run"
}
function copy_assemble_scripts() {
copy_script 'prepare'
copy_script 'save-artifacts'
copy_script 'restore-artifacts'
copy_script 'run'
}