aboutsummaryrefslogtreecommitdiffstats
path: root/s2i/bin/assemble
blob: 723d4e457209dbbfa450f1edde3253a902b853d4 (plain)
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
#!/bin/bash -e
#
# S2I assemble script for the 'kraxel/s2i-jekyll' image.
# The 'assemble' script builds your application source so that it is ready to run.
#
# For more information refer to the documentation:
#	https://github.com/openshift/source-to-image/blob/master/docs/builder_image.md
#

# If the 'kraxel/s2i-jekyll' assemble script is executed with the '-h' flag, print the usage.
if [[ "$1" == "-h" ]]; then
	exec /usr/libexec/s2i/usage
fi

set -e

echo "---> Enabling s2i support in httpd24 image ..."
source ${HTTPD_CONTAINER_SCRIPTS_PATH}/common.sh
config_s2i

if [ "$(ls /tmp/artifacts/ 2>/dev/null)" ]; then
	echo "---> Restoring build artifacts ..."
	mv /tmp/artifacts/. ./
fi

echo "---> Installing application source ..."
cp -Rf /tmp/src/. ./

if test -f Gemfile; then
	echo "---> Installing packages from Gemfile ..."
	bundle config path $(pwd)/.gem
	bundle config
	bundle install
	echo "---> Building jekyll site (gemfile version) ..."
	bundle exec jekyll build
else
	echo "---> Building jekyll site (default version) ..."
	jekyll build
fi

if test -f _config.yml; then
	base=$(awk '/^baseurl/ { print $2 }' _config.yml | tr -d '"')
else
	base=""
fi
dest="${HTTPD_APP_ROOT}/html$base"

echo "---> Copying pages to $dest ..."
pushd _site
mkdir -p "$dest"
cp -a . "$dest"
popd

echo "---> Fix permissions ..."
fix-permissions ./