#!/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 echo "--- debug ---" id -a echo "---" 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="/opt/app-root/src/documentroot$base" echo "---> Copying pages to $dest ..." pushd _site mkdir -p "$dest" cp -av . "$dest" popd echo "---> Fix permissions ..." chmod -R +r .