From 1a7d89c15403b7cd5746ab9786f34aac386a7de0 Mon Sep 17 00:00:00 2001 From: draco Date: Sun, 7 Apr 2024 20:27:37 +0800 Subject: [PATCH] Update docker startup script Signed-off-by: draco --- run.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/run.sh b/run.sh index 100dc2e..06718d8 100644 --- a/run.sh +++ b/run.sh @@ -1,5 +1,19 @@ #!/bin/bash +# Check if the environment variable VITE_BACKEND_URL is set +if [ -z "${VITE_BACKEND_URL}" ]; then + echo "VITE_BACKEND_URL is not set. Default to http://127.0.0.1:8000/" +else + # Replace the backend url with VITE_BACKEND_URL + echo "VITE_BACKEND_URL is set to ${VITE_BACKEND_URL}。" + + # Find and replace in index-*.js files within /app/dist/asserts/ + find /app/dist/asserts/ -type f -name 'index-*.js' -exec sed -i "s|http://127.0.0.1:8000/|$VITE_BACKEND_URL|g" {} \; + + echo "Backend url replacement complete." +fi + + # Start the frontend process http-server dist &