Add docker option to the tools.

This commit is contained in:
Cotes Chung
2020-10-08 16:00:08 +08:00
parent d314c02a13
commit 8f11f91677
2 changed files with 52 additions and 4 deletions

View File

@@ -16,20 +16,34 @@ CONTAINER="${WORK_DIR}/.container"
DEST="${WORK_DIR}/_site"
docker=false
_help() {
echo "Usage:"
echo
echo " bash build.sh [options]"
echo
echo "Options:"
echo " -b, --baseurl <URL> The site relative url that start with slash, e.g. '/project'"
echo " -h, --help Print the help information"
echo " -d, --destination <DIR> Destination directory (defaults to ./_site)"
echo " -b, --baseurl <URL> The site relative url that start with slash, e.g. '/project'"
echo " -h, --help Print the help information"
echo " -d, --destination <DIR> Destination directory (defaults to ./_site)"
echo " --docker Build site within docker"
}
_install_tools() {
# docker image `jekyll/jekyll` based on Apline Linux
echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories
apk update
apk add yq
}
_init() {
cd "$WORK_DIR"
if [[ -f Gemfile.lock ]]; then
rm -f Gemfile.lock
fi
if [[ -d $CONTAINER ]]; then
rm -rf "$CONTAINER"
fi
@@ -93,6 +107,10 @@ main() {
shift
shift
;;
--docker)
docker=true
shift
;;
-h | --help)
_help
exit 0
@@ -104,6 +122,10 @@ main() {
esac
done
if $docker; then
_install_tools
fi
_init
_build
}