Skip to content

Commit bde0211

Browse files
committed
Simplifies environment configuration for Azure
Removes injection-based approach in container setup Introduces fallback logic for trackmangolfdev domains Enhances runtime config generation for Azure deployments
1 parent f72c137 commit bde0211

File tree

3 files changed

+56
-10
lines changed

3 files changed

+56
-10
lines changed

β€Žeditor/Dockerfileβ€Ž

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,8 @@ COPY --from=build /app/dist /usr/share/nginx/html
6161
# Copy custom nginx config
6262
COPY nginx.conf /etc/nginx/nginx.conf
6363

64-
# Copy runtime environment injection script
65-
COPY inject-env.sh /usr/local/bin/inject-env.sh
66-
RUN chmod +x /usr/local/bin/inject-env.sh
67-
6864
# Expose port 80
6965
EXPOSE 80
7066

71-
# Use the injection script as the entrypoint
72-
CMD ["/usr/local/bin/inject-env.sh"]
67+
# Use the startup script as the entrypoint
68+
CMD ["/startup.sh"]

β€Žeditor/src/lib/env.tsβ€Ž

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ const backendBase = (() => {
3636
console.warn('[env] Using legacy VITE_GRAPHQL_URL as backend base fallback');
3737
return stripTrailingSlash(legacyGraphql.replace(/\/graphql$/, ''));
3838
}
39+
40+
// Production fallback for Azure App Service
41+
if (typeof window !== 'undefined' && window.location.hostname.includes('trackmangolfdev.com')) {
42+
return 'https://dr-cloud-api-dev.trackmangolfdev.com';
43+
}
44+
3945
return '';
4046
})();
4147

@@ -56,6 +62,12 @@ const loginBase = (() => {
5662
console.warn('[env] Using legacy VITE_OAUTH_TOKEN_URL as login base fallback');
5763
return stripTrailingSlash(legacyToken.replace(/\/connect\/token$/, ''));
5864
}
65+
66+
// Production fallback for Azure App Service
67+
if (typeof window !== 'undefined' && window.location.hostname.includes('trackmangolfdev.com')) {
68+
return 'https://tm-login-dev.trackmangolfdev.com';
69+
}
70+
5971
return '';
6072
})();
6173

@@ -87,7 +99,17 @@ function getOAuthClientId(): string {
8799
}
88100

89101
// Fall back to build-time environment variable
90-
return import.meta.env.VITE_OAUTH_WEB_CLIENT_ID || '';
102+
const buildTimeClientId = import.meta.env.VITE_OAUTH_WEB_CLIENT_ID;
103+
if (buildTimeClientId) {
104+
return buildTimeClientId;
105+
}
106+
107+
// Production fallback for Azure App Service
108+
if (typeof window !== 'undefined' && window.location.hostname.includes('trackmangolfdev.com')) {
109+
return 'dr-web.4633fada-3b16-490f-8de7-2aa67158a1d6';
110+
}
111+
112+
return '';
91113
}
92114

93115
// Function to get OAuth client secret - with runtime support
@@ -99,7 +121,17 @@ function getOAuthClientSecret(): string {
99121
}
100122

101123
// Fall back to build-time environment variable
102-
return import.meta.env.VITE_OAUTH_WEB_CLIENT_SECRET || '';
124+
const buildTimeClientSecret = import.meta.env.VITE_OAUTH_WEB_CLIENT_SECRET;
125+
if (buildTimeClientSecret) {
126+
return buildTimeClientSecret;
127+
}
128+
129+
// Production fallback for Azure App Service
130+
if (typeof window !== 'undefined' && window.location.hostname.includes('trackmangolfdev.com')) {
131+
return '7c870264-3703-4ec2-add8-5f8e57251d0e';
132+
}
133+
134+
return '';
103135
}
104136

105137
export const OAUTH_CONFIG = {

β€Žeditor/startup.shβ€Ž

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,16 @@
44

55
echo "πŸš€ Starting Azure App Service configuration..."
66

7+
# Debug: Show environment variables
8+
echo "πŸ” Environment Variables:"
9+
echo "VITE_BACKEND_BASE_URL=${VITE_BACKEND_BASE_URL:-'NOT SET'}"
10+
echo "VITE_LOGIN_BASE_URL=${VITE_LOGIN_BASE_URL:-'NOT SET'}"
11+
echo "VITE_OAUTH_WEB_CLIENT_ID=${VITE_OAUTH_WEB_CLIENT_ID:-'NOT SET'}"
12+
echo "VITE_OAUTH_WEB_CLIENT_SECRET=${VITE_OAUTH_WEB_CLIENT_SECRET:+SET}"
13+
echo "VITE_NODE_ENV=${VITE_NODE_ENV:-'NOT SET'}"
14+
715
# Create runtime configuration file
16+
echo "πŸ“„ Creating runtime configuration..."
817
cat > /usr/share/nginx/html/runtime-config.js << EOF
918
// Runtime configuration for Azure App Service
1019
window.runtimeConfig = {
@@ -16,10 +25,19 @@ window.runtimeConfig = {
1625
};
1726
1827
console.log('πŸ”§ Runtime configuration loaded for Azure App Service');
28+
console.log('πŸ“Š Config values:', window.runtimeConfig);
1929
EOF
2030

21-
echo "βœ… Runtime configuration created"
31+
echo "βœ… Runtime configuration created at /usr/share/nginx/html/runtime-config.js"
32+
33+
# Verify the file was created and show its content
34+
if [ -f "/usr/share/nginx/html/runtime-config.js" ]; then
35+
echo "πŸ“„ Runtime config file content:"
36+
head -15 /usr/share/nginx/html/runtime-config.js
37+
else
38+
echo "❌ Failed to create runtime config file!"
39+
fi
2240

2341
# Start nginx
2442
echo "🌐 Starting nginx..."
25-
nginx -g "daemon off;"
43+
exec nginx -g "daemon off;"

0 commit comments

Comments
Β (0)