Skip to content

Commit

Permalink
entrypoint
Browse files Browse the repository at this point in the history
  • Loading branch information
lvalics committed Oct 25, 2023
1 parent 119c1b6 commit 625f3d0
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions dj_backend_server/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,20 @@ CHAT_JS_FILE="/app/web/static/chat.js"
# Actual replacement
sed -i "s|http://0.0.0.0:8000|${APP_URL}|g" $CHAT_JS_FILE

# Check if /chat/init exists in the file
if grep -q "/chat/init" /app/web/static/chat.js; then
# If it exists, run the sed command
sed -i "s|/chat/init|${APP_URL}/chat/init|g" $CHAT_JS_FILE
# Check if the pattern with APP_URL already exists
if grep -q '("${APP_URL}/chat/init")' $CHAT_JS_FILE; then
echo "Pattern with APP_URL already exists, doing nothing."

# Check if the pattern with the default URL exists
elif grep -q '("http://0.0.0.0:8000/chat/init")' "$CHAT_JS_FILE"; then
echo "Replacing default URL with APP_URL."
sed -i "s|http://0.0.0.0:8000|${APP_URL}|g" "$CHAT_JS_FILE"

# If none of the above conditions are met, append APP_URL to /chat/init
else
echo "Appending APP_URL to /chat/init."
sed -i "s|/chat/init|${APP_URL}/chat/init|g" "$CHAT_JS_FILE"
fi

# Start your app normally
exec "$@"
exec "$@"

0 comments on commit 625f3d0

Please sign in to comment.