From 85f227f7d92b380a0162ad6a7e523f5d9f4d1b8d Mon Sep 17 00:00:00 2001 From: danysmall Date: Wed, 12 Oct 2022 16:44:41 +0300 Subject: [PATCH] Resolve entrypoint file bug --- entrypoint.sh | 68 +++++++++++++++++++++++++-------------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 1014a45..05eccfd 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,35 +1,35 @@ -#!/bin/bash -# no verbose -set +x -# 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" +#! /bin/bash +# no verbose +set +x +# 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 "$@" \ No newline at end of file