Add base kubernetes support 5
This commit is contained in:
@@ -35,35 +35,8 @@ COPY nginx.conf /etc/nginx/conf.d/
|
||||
# Copy built application from builder stage
|
||||
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||
|
||||
# Create a script to substitute environment variables at runtime
|
||||
COPY <<'EOF' /docker-entrypoint.d/30-substitute-env.sh
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
# Handle VITE_API_URL specially to preserve empty values
|
||||
# If VITE_API_URL is unset, use default; if empty, preserve empty; otherwise use value
|
||||
if [ -z "${VITE_API_URL+x}" ]; then
|
||||
export VITE_API_URL="/api"
|
||||
elif [ -z "$VITE_API_URL" ]; then
|
||||
# If VITE_API_URL is explicitly set to empty string, use relative API path
|
||||
export VITE_API_URL="/api"
|
||||
fi
|
||||
|
||||
# Default values for other environment variables
|
||||
export VITE_APP_TITLE=${VITE_APP_TITLE:-"PanIA Dashboard"}
|
||||
export VITE_APP_VERSION=${VITE_APP_VERSION:-"1.0.0"}
|
||||
|
||||
# Create a runtime configuration file that can be loaded by the frontend
|
||||
cat > /usr/share/nginx/html/runtime-config.js << EOL
|
||||
window.__RUNTIME_CONFIG__ = {
|
||||
VITE_API_URL: '${VITE_API_URL}',
|
||||
VITE_APP_TITLE: '${VITE_APP_TITLE}',
|
||||
VITE_APP_VERSION: '${VITE_APP_VERSION}'
|
||||
};
|
||||
EOL
|
||||
|
||||
echo "Runtime configuration created with API URL: ${VITE_API_URL}"
|
||||
EOF
|
||||
# Copy and setup environment substitution script
|
||||
COPY substitute-env.sh /docker-entrypoint.d/30-substitute-env.sh
|
||||
|
||||
# Make the script executable
|
||||
RUN chmod +x /docker-entrypoint.d/30-substitute-env.sh
|
||||
|
||||
@@ -56,7 +56,7 @@ class ApiClient {
|
||||
config: AxiosRequestConfig;
|
||||
}> = [];
|
||||
|
||||
constructor(baseURL: string = getApiUrl() + '/api/v1') {
|
||||
constructor(baseURL: string = getApiUrl() + '/v1') {
|
||||
this.baseURL = baseURL;
|
||||
|
||||
this.client = axios.create({
|
||||
|
||||
26
frontend/substitute-env.sh
Normal file
26
frontend/substitute-env.sh
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
# Handle VITE_API_URL specially to preserve empty values
|
||||
# If VITE_API_URL is unset, use default; if empty, preserve empty; otherwise use value
|
||||
if [ -z "${VITE_API_URL+x}" ]; then
|
||||
export VITE_API_URL="/api"
|
||||
elif [ -z "$VITE_API_URL" ]; then
|
||||
# If VITE_API_URL is explicitly set to empty string, use relative API path
|
||||
export VITE_API_URL="/api"
|
||||
fi
|
||||
|
||||
# Default values for other environment variables
|
||||
export VITE_APP_TITLE=${VITE_APP_TITLE:-"PanIA Dashboard"}
|
||||
export VITE_APP_VERSION=${VITE_APP_VERSION:-"1.0.0"}
|
||||
|
||||
# Create a runtime configuration file that can be loaded by the frontend
|
||||
cat > /usr/share/nginx/html/runtime-config.js << EOL
|
||||
window.__RUNTIME_CONFIG__ = {
|
||||
VITE_API_URL: '${VITE_API_URL}',
|
||||
VITE_APP_TITLE: '${VITE_APP_TITLE}',
|
||||
VITE_APP_VERSION: '${VITE_APP_VERSION}'
|
||||
};
|
||||
EOL
|
||||
|
||||
echo "Runtime configuration created with API URL: ${VITE_API_URL}"
|
||||
Reference in New Issue
Block a user