Frontend/scripts/entrypoint.sh
danysmall fecce76fe1 Improved loading content of and article with saving them in redux store
When article was loaded once than it will be cached in redux store.
On the next loading of article content it will be get from store
2022-11-12 23:41:31 +03:00

38 lines
1.0 KiB
Bash
Executable File

#! /bin/bash
# no verbose
set +x
# save env to file
printenv > .env.production
# config
envFilename='.env.production'
resolvingPath='/usr/share/nginx/html'
function apply_path {
# read all config file
while read line; do
# no comment or not empty
if [ "${line:0:1}" == "#" ] || [ "${line}" == "" ]; then
echo "Skiped line $line"
continue
fi
# split
configName="$(cut -d'=' -f1 <<<"$line")"
configValue="$(cut -d'=' -f2 <<<"$line")"
# get system env
envValue=$(env | grep "^$configName=" | grep -oP '(?!=)(?<==).*$');
if [ -z "$configValue" ]; then
echo "Empty env value met: $configName:$configValue"
fi
# if config found
if [ -n "$configValue" ] && [ -n "$envValue" ]; then
# replace all
echo "Replace: ${configValue} with: ${envValue}"
find $resolvingPath \( -type d -name .git -prune \) -o -type f -print0 | xargs -0 sed -i "s#$configValue#$envValue#g"
fi
done < $envFilename
}
apply_path
echo "Starting React Application"
exec "$@"