部署docker化
This commit is contained in:
34
deploy/frontend-entrypoint.sh
Normal file
34
deploy/frontend-entrypoint.sh
Normal file
@@ -0,0 +1,34 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
runtime_config_path="/usr/share/nginx/html/runtime-config.js"
|
||||
default_mode="${CONDO_DEFAULT_MODE:-api}"
|
||||
api_base_url="${CONDO_API_BASE_URL:-/api}"
|
||||
period_year="${CONDO_PERIOD_YEAR:-}"
|
||||
|
||||
escape_js_string() {
|
||||
printf '%s' "$1" | sed 's/\\/\\\\/g; s/"/\\"/g'
|
||||
}
|
||||
|
||||
case "$period_year" in
|
||||
"" )
|
||||
period_year_expression="new Date().getUTCFullYear()"
|
||||
;;
|
||||
*[!0-9]* )
|
||||
period_year_expression="new Date().getUTCFullYear()"
|
||||
;;
|
||||
* )
|
||||
period_year_expression="$period_year"
|
||||
;;
|
||||
esac
|
||||
|
||||
default_mode_escaped="$(escape_js_string "$default_mode")"
|
||||
api_base_url_escaped="$(escape_js_string "$api_base_url")"
|
||||
|
||||
cat > "$runtime_config_path" <<EOF
|
||||
window.CONDO_RUNTIME_CONFIG = Object.freeze({
|
||||
defaultMode: "$default_mode_escaped",
|
||||
apiBaseUrl: "$api_base_url_escaped",
|
||||
periodYear: $period_year_expression
|
||||
});
|
||||
EOF
|
||||
Reference in New Issue
Block a user