-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'v1.1.0' into bugfix/605-solr-port
- Loading branch information
Showing
7 changed files
with
83 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,66 @@ | ||
#!/bin/sh | ||
|
||
[[ -n "${DEBUG}" ]] && set -x | ||
[ -n "${DEBUG}" ] && set -x | ||
|
||
runtime_path="/usr/share/nginx/html/static/js/runtime_env.js" | ||
export RELEASE="${RELEASE:-production}" | ||
export ENV_FILE="${ENV_FILE:-/env}" | ||
export HTML_PATH="${HTML_PATH:-/usr/share/nginx/html}" | ||
export STATIC_PATH="" | ||
export STATIC_URL="${PUBLIC_URL}${STATIC_PATH}" | ||
export RUNTIME_PATH="${HTML_PATH}${STATIC_PATH}/runtime_env.js" | ||
|
||
rm -rf "${runtime_path}" && touch "${runtime_path}" | ||
TMP_PATH=/tmp | ||
|
||
echo "window.ENV = {" >> "${runtime_path}" | ||
if [ ! -e "$(dirname ${RUNTIME_PATH})" ] | ||
then | ||
mkdir -p "$(dirname ${RUNTIME_PATH})" | ||
fi | ||
|
||
while read -r line; do | ||
[[ -z "${line}" || "${line}" =~ ^# ]] && continue | ||
if [ "${RELEASE}" = "production" ] | ||
then | ||
export STATIC_PATH="/static/js" | ||
fi | ||
|
||
varname=$(printf '%s\n' "${line}" | cut -d"=" -f1) | ||
varvalue=$(printenv "${varname}") | ||
if [ -e "${ENV_FILE}" ]; then | ||
echo "window.ENV = {" > "${RUNTIME_PATH}" | ||
|
||
if [[ -z "${varvalue}" ]]; then | ||
varvalue=$(printf '%s\n' "${line}" | cut -d"=" -f2) | ||
while read -r line; do | ||
[ -z "$(echo ${line} | grep -vE '^# |^$')" ] && continue | ||
|
||
export "${varname}"="${varvalue}" | ||
fi | ||
varname=$(printf '%s\n' "${line}" | cut -d"=" -f1) | ||
varvalue=$(printenv "${varname}") | ||
|
||
echo " ${varname}: \"${varvalue}\"," >> "${runtime_path}" | ||
done < ${ENV_FILE:-/env} | ||
if [ -z "${varvalue}" ]; then | ||
varvalue=$(printf '%s\n' "${line}" | cut -d"=" -f2) | ||
|
||
echo "};" >> "${runtime_path}" | ||
export "${varname}"="${varvalue}" | ||
fi | ||
|
||
if [[ -z "${PUBLIC_URL}" ]] | ||
then | ||
envsubst '${PREVIOUS_URL}' < /nginx.conf > /etc/nginx/conf.d/default.conf | ||
export PUBLIC_URL="" | ||
else | ||
envsubst '${PREVIOUS_URL},${PUBLIC_URL}' < /nginx.subdir.conf > /etc/nginx/conf.d/default.conf | ||
echo " ${varname}: \"${varvalue}\"," >> "${RUNTIME_PATH}" | ||
done < ${ENV_FILE} | ||
|
||
echo "};" >> "${RUNTIME_PATH}" | ||
fi | ||
|
||
# prepend any "/static/... with "${PUBLIC_URL}/static/... | ||
sed -i"" "s/\"\/static/\"\${PUBLIC_URL}\/static/g" /usr/share/nginx/html/index.html | ||
if [ ! -e "/index.html" ]; then | ||
cp "${HTML_PATH}/index.html" "${TMP_PATH}/index.html" | ||
fi | ||
|
||
if [ "${RELEASE}" = "production" ] | ||
then | ||
if [ -z "${PUBLIC_URL}" ] | ||
then | ||
envsubst '${PREVIOUS_URL}' < /nginx.conf > /etc/nginx/conf.d/default.conf | ||
export PUBLIC_URL="" | ||
else | ||
envsubst '${PREVIOUS_URL},${PUBLIC_URL}' < /nginx.subdir.conf > /etc/nginx/conf.d/default.conf | ||
|
||
# move original index.html, envsubst cannot modify in place | ||
mv /usr/share/nginx/html/index.html /index.html | ||
# Fixes react-scripts static path e.g. /static/ -> $PUBLIC_URL/static/ | ||
sed -i"" "s/\"\/static\//\"\$PUBLIC_URL\/static\//g" "${TMP_PATH}/index.html" | ||
fi | ||
|
||
fi | ||
|
||
envsubst '${PUBLIC_URL},${$REACT_APP_GOOGLE_ANALYTICS_TRACKING_ID}' < /index.html > /usr/share/nginx/html/index.html | ||
envsubst '$STATIC_URL,$PUBLIC_URL,$REACT_APP_GOOGLE_ANALYTICS_TRACKING_ID' < "${TMP_PATH}/index.html" > "${HTML_PATH}/index.html" | ||
|
||
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters