-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·83 lines (68 loc) · 3.25 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·83 lines (68 loc) · 3.25 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env bash
## START STANDARD SITE BUILD SCRIPT INCLUDE
readonly THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")"
readonly BOOTSTRAP="$(dirname "$THIS_SCRIPT")/resources/bootstrap.inc.sh"
BOOTSTRAP_VERSION="$(cat "$(dirname "THIS_SCRIPT")/resources/.bootstrap-required-version")" || exit 1
readonly BOOTSTRAP_VERSION
if ! [ -f "$BOOTSTRAP" ] || ! source "$BOOTSTRAP"; then
curl -H "Cache-Control: no-cache" --fail --silent --show-error -w "curl: Finished attempt to download %{url}" "https://raw.githubusercontent.com/keymanapp/shared-sites/$BOOTSTRAP_VERSION/bootstrap.inc.sh" -o "$BOOTSTRAP.tmp" || exit 1
source "$BOOTSTRAP.tmp"
rm -f "$BOOTSTRAP.tmp"
fi
## END STANDARD SITE BUILD SCRIPT INCLUDE
readonly KEYMAN_CONTAINER_NAME=keyman-website
readonly KEYMAN_CONTAINER_DESC=keyman-com-app
readonly KEYMAN_IMAGE_NAME=keyman-website
readonly HOST_KEYMAN_COM=keyman.com.localhost
source _common/keyman-local-ports.inc.sh
source _common/docker.inc.sh
################################ Main script ################################
builder_describe \
"Setup keyman.com site to run via Docker." \
configure \
clean \
build \
start \
stop \
test \
"composer-start Start a temporary container to maintain composer" \
"composer-stop Stop and cleanup temporary container for maintaining composer" \
"--no-cache Do not use Docker build cache for 'build' step" \
"--no-unit-test" \
"--no-lint" \
"--no-link-check" \
htaccess "rebuild .htaccess from .htaccess.in (for development)"
builder_parse "$@"
function preprocess_htaccess() {
echo "# DO NOT EDIT THIS FILE -- EDIT .htaccess.in" > .htaccess
# assuming format of relevant lines in locales.json to be "tag": "name"
local locales localesregex
locales=($(cat ./_includes/locale/locales.json | grep '"' | cut -d\" -f 2 -))
localesregex=$(IFS=\| ; echo "${locales[*]}")
sed -e "s/@locales/${localesregex}/g" .htaccess.in >> .htaccess
}
function do_configure() {
preprocess_htaccess
bootstrap_configure
}
function do_start() {
# for developer convenience, rebuild .htaccess when starting container
preprocess_htaccess
start_docker_container $KEYMAN_IMAGE_NAME $KEYMAN_CONTAINER_NAME $KEYMAN_CONTAINER_DESC $HOST_KEYMAN_COM $PORT_KEYMAN_COM $BUILDER_CONFIGURATION
}
function do_test_docker_container() {
# NOTE: link checker runs on host rather than in docker image
local ignoreLocales
# determine non-en locales to ignore
ignoreLocales="$(jq -r 'keys | map(select(. != "en")) | join("|")' ./_includes/locale/locales.json)"
test_docker_container $KEYMAN_CONTAINER_DESC $PORT_KEYMAN_COM "/_test" "/(${ignoreLocales})" "/en/downloads/releases/"
}
builder_run_action configure do_configure
builder_run_action clean clean_docker_container $KEYMAN_IMAGE_NAME $KEYMAN_CONTAINER_NAME
builder_run_action stop stop_docker_container $KEYMAN_IMAGE_NAME $KEYMAN_CONTAINER_NAME
builder_run_action build build_docker_container $KEYMAN_IMAGE_NAME $KEYMAN_CONTAINER_NAME $BUILDER_CONFIGURATION
builder_run_action start do_start
builder_run_action test do_test_docker_container
builder_run_action htaccess preprocess_htaccess
builder_run_action composer-start docker_build_and_start_composer_container
builder_run_action composer-stop docker_stop_and_cleanup_composer_container