-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·36 lines (34 loc) · 1.49 KB
/
build.sh
File metadata and controls
executable file
·36 lines (34 loc) · 1.49 KB
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
#!/bin/bash
# This script exists to run a production build of the code. Users can:
# * Supply a builder image with BUILD_IMAGE_SPEC, otherwise we build the image
# * Include additional configuration overrides with ${CONFIG_OVERRIDES}, additional
# override files should be added to the project directory. Eg I add an _config-overrides.yml
# and set CONFIG_OVERRIDES=_config-overrides.yml
# * Control their container engine binary by setting CONTAINER_ENGINE, for example to 'docker'.
# The output of the build will be emitted to a '_site' directory in the project directory
trap "exit" INT
set +euo pipefail
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
cd ${SCRIPT_DIR}
CONTAINER_ENGINE=${CONTAINER_ENGINE:-podman}
if [ -z "${BUILD_IMAGE_SPEC}" ]; then
${CONTAINER_ENGINE} build . -t kroxylicious-website
export BUILD_IMAGE_SPEC=kroxylicious-website
fi
if [ -n "${CONFIG_OVERRIDES}" ]; then
export CONFIG_OVERRIDES=",${CONFIG_OVERRIDES}"
else
export CONFIG_OVERRIDES=""
fi
RUN_ARGS=()
if [ "$CONTAINER_ENGINE" = 'podman' ]; then
RUN_ARGS+=(-v "$(pwd):/site/:Z")
else
RUN_ARGS+=(-v "$(pwd):/site")
RUN_ARGS+=(-u $(id -u):$(id -g))
fi
RUN_ARGS+=(-e JEKYLL_ENV="${JEKYLL_ENV:-production}" --rm "${BUILD_IMAGE_SPEC}")
BUILD_COMMAND='eval "$(rbenv init -)" && cp -r /css/_sass/bootstrap /site/_sass/ && bundle exec jekyll build --config=_config.yml'"${CONFIG_OVERRIDES}"
RUN_ARGS+=(bash -c "${BUILD_COMMAND}")
echo "${RUN_ARGS[@]}"
${CONTAINER_ENGINE} run "${RUN_ARGS[@]}"