-
Notifications
You must be signed in to change notification settings - Fork 84
/
Copy pathstart
executable file
·52 lines (44 loc) · 1.46 KB
/
start
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
#!/bin/bash -e
source ${HOME}/etc/sdk
source ${HOME}/etc/helpers
# If the /tmp/src is empty, then print usage and exit.
(dir_is_empty /tmp/src) && print_usage_and_exit
# If the directory with sources contain '.sti' folder, then look for the
# prepare/run/etc. scripts there and replace the 'base' image scripts.
#
(! dir_is_empty /tmp/src/.sti ) && copy_assemble_scripts
while getopts “h:s:d” opt; do
case $opt in
h)
print_usage_and_exit
;;
s)
download_assemble_scripts "${OPTARG}"
;;
d)
exec /bin/bash
;;
esac
done
# Detect the presence of $stdin and restore the artifacts
# To restore the artifacts, you have to run the builder as:
#
# docker run -v $(pwd):/tmp/src openshift/centos-ruby-builder < artifacts.tgz
#
if [ -p /dev/stdin ]; then
echo "---> Restoring artifacts"
cat | ${HOME}/bin/restore-artifacts
fi
# Prepare the Ruby application source code which includes:
#
# * (optional) Restore artifacts (bundle/vendor) from the previous build
# * Installing all rubygems dependencies using Bundler
# * (optional) Complilation of the Rails assets (rake assets:precompile)
#
${HOME}/bin/prepare
echo "---> Build successful. Commit this image with: 'docker commit ${HOSTNAME} ruby-app'"
# Once the Ruby application sources are prepared, replace
# this script with the 'run' script that launch the application
# using Ruby application server (puma or rackup by default).
#
cp -f ${HOME}/bin/run ${HOME}/bin/start && exit