FrontendOld/dev-entrypoint.sh
2024-07-04 11:46:38 +02:00

35 lines
No EOL
781 B
Bash
Executable file

#!/bin/sh
# Set default API_URL
DEFAULT_API_URL="http://localhost:4000/api"
# Print current directory
echo "Current directory: $(pwd)"
# Check if the .env file exists and is non-empty
if [ -s .env ]; then
# Read the API_URL variable directly from the .env file
API_URL=$(grep -E '^API_URL=' .env | cut -d= -f2-)
# Check if API_URL is set
if [ -z "$API_URL" ]; then
echo "Error: API_URL is not set in the .env file."
exit 1
else
echo "API_URL is $API_URL"
fi
else
echo ".env file not found or empty, using default API_URL: $DEFAULT_API_URL"
API_URL="$DEFAULT_API_URL"
fi
# Attempt to create or update the config.json file
if ! cat > ./public/config.json <<EOF
{
"apiUrl": "$API_URL"
}
EOF
then
echo "Failed to write to config.json"
exit 1
fi