11#! /bin/bash
2+ set -e
23# Azure App Service startup script
34# This script creates a runtime configuration file from environment variables
45
@@ -16,31 +17,48 @@ echo "VITE_OAUTH_WEB_CLIENT_ID='${VITE_OAUTH_WEB_CLIENT_ID:-NOT SET}'"
1617echo " VITE_OAUTH_WEB_CLIENT_SECRET='${VITE_OAUTH_WEB_CLIENT_SECRET: +SET} '"
1718echo " VITE_NODE_ENV='${VITE_NODE_ENV:- NOT SET} '"
1819
20+ # DEBUG: Check if file exists before writing
21+ echo " π Checking if runtime-config.js exists before writing..."
22+ ls -la /usr/share/nginx/html/runtime-config.js 2> /dev/null || echo " File doesn't exist yet"
23+
24+ # Check directory permissions
25+ echo " π Directory permissions:"
26+ ls -la /usr/share/nginx/html/
27+
1928# Create runtime configuration file
2029echo " π Creating runtime configuration..."
30+ TIMESTAMP=$( date -u +" %Y-%m-%dT%H:%M:%SZ" )
2131cat > /usr/share/nginx/html/runtime-config.js << EOF
22- // Runtime configuration for Azure App Service
32+ // Runtime configuration for Azure App Service - Generated: ${TIMESTAMP}
2333window.runtimeConfig = {
2434 VITE_BACKEND_BASE_URL: '${VITE_BACKEND_BASE_URL} ',
2535 VITE_LOGIN_BASE_URL: '${VITE_LOGIN_BASE_URL} ',
2636 VITE_OAUTH_WEB_CLIENT_ID: '${VITE_OAUTH_WEB_CLIENT_ID} ',
2737 VITE_OAUTH_WEB_CLIENT_SECRET: '${VITE_OAUTH_WEB_CLIENT_SECRET} ',
28- VITE_NODE_ENV: '${VITE_NODE_ENV} '
38+ VITE_NODE_ENV: '${VITE_NODE_ENV} ',
39+ _generated: '${TIMESTAMP} '
2940};
3041
3142console.log('π§ Runtime configuration loaded for Azure App Service');
3243console.log('π Config values:', window.runtimeConfig);
44+ console.log('π Generated at: ${TIMESTAMP} ');
3345EOF
3446
3547echo " β
Runtime configuration created at /usr/share/nginx/html/runtime-config.js"
3648
37- # Verify the file was created and show its content
38- if [ -f " /usr/share/nginx/html/runtime-config.js" ]; then
39- echo " π Runtime config file content:"
40- head -15 /usr/share/nginx/html/runtime-config.js
41- else
42- echo " β Failed to create runtime config file!"
43- fi
49+ # DEBUG: Verify what was actually written
50+ echo " π Runtime config file content after writing:"
51+ cat /usr/share/nginx/html/runtime-config.js
52+
53+ # DEBUG: Check file permissions after writing
54+ echo " οΏ½ File permissions after writing:"
55+ ls -la /usr/share/nginx/html/runtime-config.js
56+
57+ # DEBUG: Test file can be read by nginx user
58+ echo " π Testing nginx config:"
59+ nginx -t 2> /dev/null && echo " β
Nginx config valid" || echo " β Nginx config error"
60+
61+ echo " β
Runtime configuration setup complete!"
4462
4563# Start nginx
4664echo " π Starting nginx..."
0 commit comments